C-study/06/4/c31.c

24 lines
307 B
C

#include<stdio.h>
int sum(int i){
int n=0;
while(i){
n+=i%10;
i/=10;
}
return n;
}
int main(){
int a[20],n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++){
printf("%d ",sum(a[i]));
}
return 0;
}