标签:ring mem contain tom between com include marked ram
#include <iostream> #include <algorithm> #include <stdio.h> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <ctype.h> using namespace std; char num[105]; int sum[1000]; void add(char a[]) { int z=0; for(int i=strlen(a)-1;i>=0;i--) { sum[z]+=a[i]-‘0‘; sum[z+1]+=sum[z]/10; sum[z]%=10; z++; } } int main() { int t,i; scanf("%d",&t); while(t--) { memset(num,‘ ‘,sizeof(num)); memset(sum,0,sizeof(sum)); while(scanf("%s",num)&&strcmp(num,"0")) add(num); for(i=999;i>=0;i--) if(sum[i]) break; if(i<0) printf("0"); for(;i>=0;i--) printf("%d",sum[i]); printf("\n"); if(t!=0) printf("\n"); } return 0; }
标签:ring mem contain tom between com include marked ram
原文地址:http://www.cnblogs.com/gonsedup/p/7262313.html