解题思路:在写循环的时候就将参数p加入到循环中,这样就可以省掉一个循环。
注意事项:注意数组的大小
参考代码:
#include<iostream>
#include<cstring>
#include<cstdio>
const int manx=10000+5;
using namespace std;
int main()
{
int t,n;
int p=0,q=0;
int a[manx];
while(scanf("%d",&t)==1&&t!=0)
{
int p=0,q=0;
for(int i=0;i<t;i++)
{
scanf("%d",&a[i]);
p+=a[i];
}
printf("%d\n",p);
}
return 0;
}
0.0分
0 人评分
C语言训练-自守数问题 (C语言代码) long long浏览:1084 |
点我有惊喜!你懂得!浏览:2104 |
【亲和数】 (C语言代码)浏览:538 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:432 |
sizeof的大作用 (C语言代码)浏览:1126 |
C语言训练-亲密数 (C语言描述,反正怎么都能对)浏览:2245 |
C二级辅导-进制转换 (C语言代码)浏览:743 |
字符逆序 (C语言代码)浏览:669 |
数组输出 (C语言代码)浏览:745 |
淘淘的名单 (C语言代码)浏览:1292 |