题目链接:
#include#include #include #define Max 110using namespace std;int temp[Max];int sum[Max];int main(){ memset(sum,0,sizeof(sum)); char tmp_string[Max]; while(scanf("%s",tmp_string),strcmp(tmp_string,"0")) { _strrev(tmp_string); memset(temp,0,sizeof(temp)); int len=strlen(tmp_string); for(int i=0; i 9) { sum[i]=sum[i]-10; sum[i+1]++; } } } int pos=0; for(int i=104;i>=0;i--) { if(sum[i]!=0) { pos=i; break; } } for(int i=pos;i>=0;i--) printf("%d",sum[i]); //puts(""); return 0;}
#include#include #define Max 1000005int a[Max];int b[Max];int sum[Max];int main(){ memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(sum,0,sizeof(sum)); int N; scanf("%d",&N); getchar(); for(int i=N-1; i>=0; i--) { a[i]=getchar()-'0'; getchar(); b[i]=getchar()-'0'; getchar(); //scanf("%d%d",&a[i],&b[i]); } for(int i=0; i 9) { sum[i]=sum[i]-10; sum[i+1]++; } } if(sum[N]) printf("%d",sum[N]); for(int i=N-1; i>=0; i--) { //printf("%d",sum[i]); putchar(sum[i]+'0'); } return 0;}