array_demo.c 307 B

12345678910111213141516
  1. #include <stdio.h>
  2. int main() {
  3. //数组声明
  4. int numbers[5];
  5. //从标准输入(控制台)读取输入
  6. for(int i = 0;i < 5; i++)
  7. scanf("%d", &numbers[i]);
  8. //计算总和
  9. int result = 0;
  10. for(int i=0; i < 5; i++)
  11. result += numbers[i];
  12. printf("sum:%d\n", result);
  13. return 0;
  14. }