请这是一个C问题. [英] Please this is a C question.

查看:60
本文介绍了请这是一个C问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个程序,询问用户要输入多少个整数.然后向用户询问那么多数字.打印出数字和平均值的总和.

write a program that asks the user for how many integer numbers to input. Then ask the user for that many numbers. Print out the sum of the numbers and the average.

推荐答案

这似乎是学校或大学的作业,假设您的老师或讲师也在阅读这些论坛.

您应该先在自己身边尝试一些事情,然后在遇到问题时提出问题.您必须尝试此处 [如何问一个好问题? [ ^ ]
This seems like school or university assignment, assume that your teacher or lecturer is also reading these forums.

You should try something by your side first and then post question if you get stuck somewhere. You MUST try here[^] first.

You must refer How to ask a good question?[^]


我们不会做你的作业...

但是:
We won''t do your homework...

But:

  1. 了解如何在控制台中显示消息( printf 可以做到).
  2. 了解如何获取用户输入的号码. scanf 或类似的功能将为您提供帮助.
  3. 了解在这种情况下如何循环使用 for 循环将执行此操作,因为您知道必须要处理多少个数字
  4. 要聪明,只使用一个数字变量来存储和并在循环内增加该变量.

  1. Learn how to show messages in the console (printf will do it).
  2. Learn to get numbers entered by the user. scanf or similar functions will help you.
  3. Learn how to loop in that case a for loop will do it as you know how many numbers have to be asked.
  4. Be clever and use only a numeric variable to store the sum and increase that variable inside the loop.


注意:请注意,如果输入大数字,加法时可能会溢出.

现在,有了所有这些信息,您就可以开始使用Google来学习功能的工作原理.然后我的建议是,您应该使用笔和纸来设计应用程序,最后您应该开始编程.

分而治之! < =这是一个可以给您的最有用的提示之一.它始终有效,并且是唯一的方法.

祝你好运!


Note: be careful, if you enter big numbers you can suffer from overflow when making the addition.

Now, with all that information, you can start using google to learn how the functions work. Then my recommendation is that you should design the app using a pencial and a paper, and at the end you should start programming.

Divide and conquer! <= this is one of the most useful tips one can give you. It always works and it is the only way to do it.

Good luck!


这篇关于请这是一个C问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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