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:疯了!!!!!!!!!结果都对,就是不ACIn Reply To:疯了!!!!!!!!!结果都对,就是不AV Posted by:wzf123 at 2006-07-23 17:07:18 #include <stdio.h> int oper(int n,int s[]) { int i=-1; while(n) { s[++i]=n%10; n=n/10; } return i; } int main() { int oper(int n,int s[]); long int n; long int m; int a[20]={0},b[20]={0},i,j,k,z,time,leap=0; while(0!=scanf("%u%u",&n,&m)) { if(n==0&&m==0)break; i=oper(n,a); j=oper(m,b); if(i>j)z=j; else z=i; for (k=0,time=0,leap=0;k<=z+1;k++) { if(a[k]+b[k]+leap>=10) { time++; leap=1; } else leap=0; } if(time==0) printf("No carry operation.\n"); if(time==1) printf("1 carry operation.\n"); if(time>1) printf("%d carry operations.\n",time); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator