|  | 
|  | 
| back to board | c program wa#4 hello. can you help me.what is the test 4. where can i find it.
 #include <stdio.h>
 
 int a[1000000],b[1000000] ,c[1000000];
 void main()
 {
 int n,i,cr=0;
 scanf("%d",&n);
 
 for(i=0;i<n;i++)
 {
 scanf("%d %d",&a[i],&b[i]);
 }
 for(i=n-1;i>=0;i--)
 {
 c[i  ]= (a[i]+b[i])%10+cr;
 cr= (a[i]+b[i]+cr)/10;
 }
 for(i=0;i<n;i++)
 {
 printf("%d",c[i]);
 }
 }
Re: c program wa#4 Try21
 3 4
 9 0
 0 9
 1 8
 2 7
 3 6
 4 5
 5 4
 6 3
 7 2
 8 1
 9 0
 0 9
 1 8
 2 7
 3 6
 4 5
 5 4
 6 3
 7 2
 9 1
 
 Hint: try not to use arrays at all
 
 Edited by author 18.07.2011 16:02
Re: c program wa#4 thank you for your help. i am accepted.Re: c program wa#4 now i just use one array and got accepted.0.671    4 032 KB
 
 Edited by author 21.07.2011 16:27
Re: c program wa#4 congrats, but try not to use arrays at all! | 
 | 
|