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 |
各位路过的牛人帮忙看看为啥wa?讨论的数据都过啦~汗~多谢各位了#include <iostream> using namespace std; int flag=0; char jia(char a,char b) { char s; if (flag==1) { if (a!=b) { s='0'; flag=1; } else { s='1'; if(a=='1') flag=1; else flag=0; } } else { if (a!=b) { s='1'; flag=0; } else { s='0'; if (a=='1') flag=1; else flag=0; } } return s; } int main() { //char a[100]={0},b[100]={0},s[100]={0},d[200]={0}; int m,n,i,j,k,o,flag=0; cin>>n; for (i=0;i<n;i++) { char a[100],b[100],s[100],d[200]; for (m=0;m<100;m++) { a[m]=b[m]=s[m]='0'; } for (m=0;m<200;m++) d[m]=' '; fflush(stdin); gets(d); for (j=0;;j++) { if (d[j]==' ') { j++; a[j]='\0'; break; } a[j]=d[j]; } for (k=j;;k++) { if (d[k]=='\0') { b[k-j+1]='\0'; break; } b[k-j]=d[k]; } k=k-j; j--; o=0; while (j>0&&k>0) { s[o++]=jia(a[--j],b[--k]); } if (k>0) { while(k>0) s[o++]=jia(b[--k],'0'); } if (j>0) { while(j>0) s[o++]=jia(a[--j],'0'); } s[o++]=jia('0','0'); cout<<(i+1)<<" "; flag=0; for (k=o-1;k>=0;k--) { if (s[k]!='0') flag=1; if (flag==1) cout<<s[k]; else if (k==0) cout<<s[k]; else continue; } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator