奇闻趣事,请帮帮我 [英] Gonzo, help me please
本文介绍了奇闻趣事,请帮帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要编写一个程序,要求用户输入两个整数。然后程序将询问用户四个字母a中的一个来添加数字,s来减去数字,m来乘以数字,或者d来分割这两个数字。
如果用户输入除列出的4个字符以外的任何字符,请不断询问它们,直到输入正确的字母为止。在显示器上显示两个数字输入使用的数学运算和操作的答案:
你的目标名称是什么? PM它
I''m suppose to write a program that will ask the user to enter two integers. Then the program will ask the user for one of four letters a to add the numbers, s to subtract the numbers, m to multiply the numbers, or d to divide the two numbers.
If the user enters any character other than the 4 listed, keep asking them over and over until they enter a correct letter. Display on the monitor the two numbers entered the math operation used and the answer of the operation:
What''s your aim name? PM it
推荐答案
是否应该对数字进行任何错误检查?或者只是为了字母?
你需要做的就是两个数字,然后输入一个while循环。 while循环将具有char i ==''''或i =='s''或i ==''m''或i ==''d''的条件。当你在那个循环中,cin i。
然后,你可以使用if语句或switch语句来执行正确的操作。
Is there supposed to be any error-checking for the numbers? Or just for the letters?
All you need to do is cin two numbers, then enter a while loop. The while loop will have a condition that a char i == ''a'' or i == ''s'' or i == ''m'' or i == ''d''. While you are in that loop, cin i.
Then, you can either use if statements or a switch statement to do the correct operation.
是否应该对数字进行任何错误检查?或者只是为了字母?
你需要做的就是两个数字,然后输入一个while循环。 while循环将具有char i ==''''或i =='s''或i ==''m''或i ==''d''的条件。当你在那个循环中时,cin i。
然后,你可以使用if语句或switch语句来执行正确的操作。
Is there supposed to be any error-checking for the numbers? Or just for the letters?
All you need to do is cin two numbers, then enter a while loop. The while loop will have a condition that a char i == ''a'' or i == ''s'' or i == ''m'' or i == ''d''. While you are in that loop, cin i.
Then, you can either use if statements or a switch statement to do the correct operation.
只是字母
Just the letters
那么你就明白了。
这篇关于奇闻趣事,请帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文