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 |
Re:我也找遍了整个dicuss了,我都通过啦,注意的问题也注意了但是WA了N遍啊大神帮助啊In Reply To:我也找遍了整个dicuss了,我都通过啦,注意的问题也注意了但是WA了N遍啊大神帮助啊 Posted by:mcgrady3 at 2011-11-01 13:13:48 > #include <stdio.h> > #include <string.h> > #define MAX 300 > int main() > { > int i=0,j,len; > char line[MAX]; > int ans[MAX],com[MAX]; > memset(ans,0,sizeof(ans)); > scanf("%s",line); > if(line[0]=='0') > return 0; > for(j=strlen(line)-1;j>=0;j--) /*i=0是ans的个位,这里是转换*/ > ans[i++]=(line[j]-'0'); > while(scanf("%s",line)!=EOF) > { > if(line[0]=='0') > break; > j=0; > memset(com,0,sizeof(com)); > for(i=strlen(line)-1;i>=0;i--) > com[j++]=(line[i]-'0'); > i=0; > while((ans[i]>=0||com[i]>=0)&&(i<MAX)) > { > if((ans[i]+com[i])>9) > { > ans[i]=ans[i]+com[i]-10; > ans[i+1]++; > } > else > ans[i]=ans[i]+com[i]; > i++; > } > } > bool start=false; > for(i=MAX-1;i>=0;i--) > if(start) > printf("%d",ans[i]); > else if(ans[i]) > { > printf("%d",ans[i]); > start=true; > } > return 0; > } > > 大神帮助啊 编译器用得G++ 或C++都不行 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator