我需要一个程序的帮助

编程入门 行业动态 更新时间:2024-10-28 09:14:56
本文介绍了我需要一个程序的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Wrire一个程序,一次一个地询问用户一系列整数。当用户输入整数0时,程序显示以下信息。 1)系列中的整数数(不包括零) 2 )整数的平均值 3)系列中最大的整数 4)系列中的最小整数 5)范围(最大和最小整数之间的差异) 我到目前为止所有这一切都被卡住了。 #include< iostream.h> #include< string.h> #include< iomanip.h> main( ) { int number; int number2; int number3; int total; int average; int counter; int maximum; int smallest = 130000; int difference; int addition; do { cout<< 输入一系列整数,完成后输入0。 << ''\ n''; cin>>数字; if(number!= 0) {

"Wrire a program that asks the user for a series of integers one at a time. When the user enters the integer 0, the program displays the following information. 1) the number of integers in the series (not including zero) 2) the average of the integers 3) the largest integer in the series 4) the smallest integer in the series 5) the range (difference between largest and smallest integer) All I have is this so far, i''m stuck. #include <iostream.h> #include <string.h> #include <iomanip.h> main() { int number; int number2; int number3; int total; int average; int counter; int largest; int smallest = 130000; int difference; int addition; do { cout << "Enter a series of integers, enter 0 when you''re done." << ''\n''; cin >> number; if (number != 0) {

推荐答案

当然你必须因为你在节目中的第一行错了所以被卡住了! ... cout<< 输入一系列整数,完成后输入0。 << ''\ n''; cin>>数字; 如何从用户那里请求一系列整数然后只需要一个!! 你不能说cin>>数字;因为这只接受将要输入的第一个数字而忽略其余的数字? 而不是你应该说cout<<<"多少数字?"<< endl; cin>> n; cout<<" plz输入"<< endl; For (int i = 0; i< n; i ++) cin>> a [i]; 其中n是他们的数字(12号4例子)和a [i]是你将存储这些数字的数组... i希望你得到那么小的一部分...如果你需要更多帮助.......发布! Sure You must be stuck since your first line in the program is wrong !! ... cout << "Enter a series of integers, enter 0 when you''re done." << ''\n''; cin >> number; how can you request a series of integers from a user and then expects only one !! you can''t say cin>>number ; coz this will accepts only the first number that will be entered and ignores the rest ?? instead you should say cout<<"how many numbers ?"<<endl; cin>>n; cout<<"plz enter them "<<endl; For (int i=0;i<n;i++) cin>>a[i] ; where n is their number ( 12 number 4 example) and a[i] is the array at which you will store these numbers ... i hope you get that small part ...if u need more help .......post !

您确定它只接受一个号码吗?我看到其他人这样做了,他们完成了程序..它工作了! 顺便说一句,我正在使用do while循环编写这个程序。 Are you sure it will only accept one number? I saw someone else do it like that, and they finished the program.. and it worked! By the way, im writing this program using a do while loop.

当然使用do while是另一回事... 使用任何循环都可以完成这项任务... for,while,do..while ,... 那你现在的问题是什么? Of course Using a do while is a different matter ... using any loop will do the job ... for ,while , do..while ,... so what is your problem now ??

更多推荐

我需要一个程序的帮助

本文发布于:2023-11-07 22:12:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567572.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!