我该如何计算这样的东西? [英] How do I compute something like this?

查看:83
本文介绍了我该如何计算这样的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。在不使用乘法(*)运算符的情况下计算两个数的乘积。考虑样品输出。

输入第一个数字:2

输入第二个数字:2

产品:4



2.使用do-while循环,编写一个程序,要求用户输入整数。显示从1到用户输入的所有偶数和奇数。考虑样本输出。

输出:

输入一个整数:10

奇数从1到10:1 3 5 7 9

偶数从1到10:2 4 6 8 10



3.使用do-while循环,编写一个要求的程序五(5)个整数。确定最高和最低值。

考虑样本输出。

输出:

输入第一个数字:5

输入第二个数字:10

输入第3个数字:2

输入第4个数字:50

输入第5个数字:30



最高价值是:50

最低价值是:2



4.使用for循环,编写一个程序,要求用户输入整数。计算因子值。因子是小于或等于n的所有正整数的乘积。

示例:5! = 5 * 4 * 3 * 2 * 1 = 120

考虑样本输出:

输入一个整数:5

阶乘5是:120



5.使用嵌套循环,编写一个要求整数的程序。基于输入显示以下输出。

例如:

输入一个数字:5

*

**

***

****

*****



我有什么试过:



#include

1. Calculate the product of two numbers without using the multiplication (*) operator. Consider the sample output.
Enter 1st number: 2
Enter 2nd number: 2
Product: 4

2. Using do-while loop, write a program that will ask the user to input an integer number. Display all even and odd numbers from 1 to the user’s input. Consider the sample output.
Output:
Enter an integer number: 10
Odd numbers from 1 - 10: 1 3 5 7 9
Even Numbers from 1 - 10: 2 4 6 8 10

3. Using do-while loop, Write a program that will ask for five (5) integer numbers. Determine the highest and lowest value.
Consider the sample output.
Output:
Enter 1st number: 5
Enter 2nd number: 10
Enter 3rd number: 2
Enter 4th number: 50
Enter 5th number: 30

The highest value is: 50
The lowest value is: 2

4. Using for loop, Write a program that will ask the user to input an integer number. Compute for the factorial value. Factorial is the product of all positive integers less than or equal to n.
Example: 5! = 5*4*3*2*1 = 120
Consider the sample output:
Enter an integer number: 5
The factorial of 5 is: 120

5. Using nested loop, write a program that will ask for an integer number. Based from the input display the following output.
Example:
Enter a number: 5
*
**
***
****
*****

What I have tried:

#include

推荐答案

我们不做你的HomeWork。 />
HomeWork不会在乞求其他人做你的工作时测试你的技能,它将帮助你的老师检查你对你所学课程的理解以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,试一试,重读你的课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个确切的问题,我们可能会提供帮助。



自己要解决这些问题,你会学到一些东西。

重读你的课程。
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

It is be solving the exercises yourself that you will learn something.
Reread your courses.


开始考虑所需的算法。

例如,如果没有实际乘法,你如何计算两个数的乘积?嗯,这并不难,没有那么多的数学运算比乘法更简单。找到每个问题的正确算法后,尝试对其进行编码,如果您遇到问题,请在此处询问具体问题。
Start thinking about the algorithms required.
For instance how would you compute the product of two numbers without actual multiplication? Well it is not hard, there aren't so many mathematical operations simpler than multiplication. Once you find the right algorithm for each problem, try to code it, and if you are stuck on that then ask here specific questions.


这篇关于我该如何计算这样的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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