帮助exponents循环,不允许使用pow()库 [英] Help with exponents loop, not allowed to use pow() library

查看:51
本文介绍了帮助exponents循环,不允许使用pow()库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图建立这个指数循环,请记住这是我在计算机科学的第一年,所以我对脚本的了解有点微不足道。基本上这个分配(或至少它的一部分)告诉我们让用户输入2个数字(左和右)并使用循环输出正确的答案来计算。我的想法是用来编写一个脚本,以便用户输入右侧的数字将决定循环运行的次数。这是我到目前为止所做的,但它不起作用。任何人都可以帮忙吗?

so i''m trying to set up this exponents loop, keep in mind this is my first year in computer science so my knowledge of script is somewhat minimal. basically this assignment (or at least part of it) tells us to have the user enter 2 numbers, (left and right) and to output the correct answer using a loop to calculate. my idea was to use to write a script so the number the user inputs for the right side will determine the number of times the loop runs. this is what i have so far but it''s not working. can anyone help please?

展开 | 选择 | Wrap | 行号

推荐答案

好吧,你的for循环几乎没有丢失。


您尝试实施的逻辑是什么?如果给你一张纸和数字,你将如何完成这项任务?这些步骤中的每一步都是您的算法,您需要在开始编码之前弄清楚。我建议读取数字和指数,然后在你的for循环中使用指数作为测试限制。
Well, your for loop is missing just about everything.

What is the logic you are trying to implement? How would you accomplish this task if you were given a piece of paper and the numbers? Each of those steps is your algorithm, which you need to figure out before you start coding. I would recommend reading in the number and the exponent, and then using the exponent as the test limit in your for loop.


我不确定我是否完全理解你,因为我我已经这样做了几个月,但我会尽力表达自己。


基本上我想做的就是让用户输入两个数字,(左和右),然后像这样计算:

剩下^右边

但是我不能用pow()

我不太确定你所说的读入是什么意思虽然

我真的不知道这个任务,不知道该怎么办

你觉得我走在正确的轨道上吗?


#include< iostream>


使用命名空间std;


int main()

{

int left,right,count,answer;


cout<< 输入左侧和右侧:;

cin>>左>>对吧;





{

left * = right;

} while(count = right);






system(" ;暂停");

返回0;

}
i''m not sure if i understand you completely, as i''ve been only doing this for a few months, but i''ll try express myself the best i can.

basically what i''m trying to do is have the user enter in two numbers, (left and right) and then calculating it like this:
left ^ right
but i can''t use pow()
i''m not too sure what you meant by "reading in" though
i''m still at a loss for this assignment really, no idea what to do
do you think im on the right track?

#include <iostream>

using namespace std;

int main()
{
int left, right, count, answer;

cout << "Enter left and right side: ";
cin >> left >> right;



do
{
left *= right;
} while (count = right);







system("pause");
return 0;
}


好的。关闭编译器/ IDE。保持关闭状态。


拿笔(或铅笔)和一张纸。现在,在不使用代码的情况下,记下任何不知道如何计算指数的人都能够获取,阅读和关注的步骤。例如,你将从基础开始:


得到基础

得到指数


从那里,其中你会去吗?你怎么做才能计算出力量?您采取了哪些步骤(当您不允许使用计算器时)?你需要弄明白这一点,看看真实世界的行为,然后才能将其概念化到足以将其抽象到计算机上。
Okay. Close your compiler/IDE. Leave it closed.

Take a pen (or pencil) and a sheet of paper. Now, without using code, write down the steps that anyone who did not know how to calculate an exponent would be able to pick up, read, and follow. For example, you would start with the basics:

get base
get exponent

from there, where would you go? What do you do to calculate a power? What steps do you take (when you''re not allowed to use a calculator)? You need to figure this out, and look at how the real-world behaves before you can conceptualize it enough to abstract it to a computer.


这篇关于帮助exponents循环,不允许使用pow()库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆