刷题碰到这种题目,但不知道C语言怎么实现这种题目,scanf函数好像不行,请各位指教
当然用scanf,为啥不行?
供参考:
#include <stdio.h>
int main()
{
int C, N, n, s;
scanf("%d", &C);
while (C--) {
s = 0;
scanf("%d", &N);
while (N--) {
scanf("%d", &n);
s += n;
}
printf("S=%d\n", s);
}
return 0;
}