解题思路:通过循环解决问题
注意事项:
参考代码
:#include <stdio.h>
int main()
{
int n, m, i, sum = 0, j, a;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &m);
for (j = 0; j < m; j++)
{
scanf("%d", &a);
sum = sum + a;
}
printf("%d", sum);
}
return 0;
}
0.0分
1 人评分
#include <stdio.h> int main() { int a, i; int j, m; int sum = 0; int arr[100] = {0}; scanf("%d", &i); for (j = 0; j < i; j++) { scanf("%d", &m); for (a = 0; a < m; a++) { scanf("%d", &arr[a]); sum += arr[a]; } printf("%d\n", sum); sum = 0; } }
代码不对,sum没初始化
HashMap 2022-12-26 22:02:46 |
#include <stdio.h> int main() { int a, i; int j, m; int sum = 0; int arr[100] = {0}; scanf("%d", &i); for (j = 0; j < i; j++) { scanf("%d", &m); for (a = 0; a < m; a++) { scanf("%d", &arr[a]); sum += arr[a]; } printf("%d ", sum); sum = 0; } }
输出九九乘法表 (C语言代码)浏览:1649 |
C语言训练-亲密数 (C++代码)浏览:798 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:703 |
震宇大神的杀毒软件 (C++代码)浏览:1173 |
C二级辅导-统计字符 (C语言代码)浏览:528 |
C语言训练-大、小写问题 (C语言代码)浏览:2421 |
九宫重排 (C++代码)浏览:1410 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:643 |
Pascal三角 (C语言代码)格式错误浏览:551 |
三角形 (C++代码)记忆化搜索浏览:1317 |