Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
数组非要200才过。。。。。#include<stdio.h> #include<stdlib.h> #include<string.h> #define max 201 int turn[max+20]={0}; int answer[max+20]={0}; char number[max+20] ; int main() { while(1) { scanf("%s",number); if(strcmp(number,"0")==0) break; memset(turn,0,sizeof(turn)); int j=0; int length=strlen(number); for(int i=length-1;i>=0;i--) { turn[j]=number[i]-'0'; j++; } for(int i=0;i<max;i++) { answer[i]=answer[i]+turn[i]; if(answer[i]>=10) { answer[i]-=10; answer[i+1]++; } } } bool jump=false; int sum=0; int i; for(i=0;i<max;i++) { sum=answer[i]+sum; } if(sum==0) printf("%d",sum); else { for(int i=max-1;i>=0;i--) { if(jump) { printf("%d",answer[i]); } else if(answer[i]) { printf("%d",answer[i]); jump=true; } else continue; } } printf("\n"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator