Revision en2, by dush1729, 2015-09-20 10:54:19

Hi i am trying to solve above problem and getting WA. Help. [code]#include<stdio.h> int main() { int T; scanf("%d",&T); while(T--) { char a[1000]; int i,b=0,c=0,d=0; fflush(stdin); gets(a); fflush(stdin); gets(a); for(i=0;a[i]!=' ';i++) { if(a[i]=='m') { b=-1; break; } b=b*10+(a[i]-'0'); } for(;a[i]!=' ';i++); i+=3; for(;a[i]!=' ';i++) { if(a[i]=='m') { c=-1; break; } c=c*10+(a[i]-'0'); } for(;a[i]!=' ';i++); i+=3; for(;a[i]!='\0';i++) { if(a[i]=='m') { d=-1; break; } d=d*10+(a[i]-'0'); } if(b==-1) printf("%d + %d = %d\n",d-c,c,d); else if(c==-1) printf("%d + %d = %d\n",b,d-b,d); else printf("%d + %d = %d\n",b,c,b+c); } return 0; }[/code]

Tags spoj, wa, string

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English dush1729 2015-09-20 11:27:31 83
en4 English dush1729 2015-09-20 10:58:58 22 Tiny change: 'turn 0;\n}/code]' -
en3 English dush1729 2015-09-20 10:56:22 11
en2 English dush1729 2015-09-20 10:54:19 13
en1 English dush1729 2015-09-20 10:53:28 1164 Initial revision (published)