枯叶凋零


私信TA

用户名:15102911975

访问量:4374

签 名:

等  级
排  名 5816
经  验 1425
参赛次数 1
文章发表 9
年  龄 0
在职情况 学生
学  校 陕西科技大学
专  业

  自我简介:

解题思路:在写循环的时候就将参数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 人评分

  评论区