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 |
求高人帮我看一下~~!!测试没问题!提交就错误答案 ~~不胜感谢!!#include <iostream.h> #include <string.h> #include <stdlib.h> class Case { public: char c_fbit[82]; char fbit[82]; char c_ebit[82]; char ebit[82]; char rbit[83]; void init(){ cin>>c_fbit; cin>>c_ebit; inversion(); } void inversion(){ int k=0; for(int j=0;j<=81;j++){ if(c_fbit[j]==0){ k=j; } } int i=0; while(k!=0){ fbit[81-k]=c_fbit[i]; i++; k--; } k=0; for(j=0;j<=81;j++){ if(c_ebit[j]==0){ k=j; } } i=0; while(k!=0){ ebit[81-k]=c_ebit[i]; i++; k--; } } void addition(){ int rbit_index=81; char temp='0'; for(int j=80;j>=0;j--){ if(temp=='1'){ if(fbit[j]=='1'&&ebit[j]=='1'){ rbit[rbit_index]='1'; rbit_index--; temp='1'; continue; }else if(fbit[j]=='1'&&ebit[j]=='0'||fbit[j]=='0'&&ebit[j]=='1'){ rbit[rbit_index]='0'; rbit_index--; temp='1'; continue; }else if(fbit[j]=='0'&&ebit[j]=='0'){ rbit[rbit_index]='1'; rbit_index--; temp='0'; continue; } }else{ if(fbit[j]=='1'&&ebit[j]=='1'){ rbit[rbit_index]='0'; rbit_index--; temp='1'; continue; }else if(fbit[j]=='1'&&ebit[j]=='0'||fbit[j]=='0'&&ebit[j]=='1'){ rbit[rbit_index] = '1'; rbit_index--; temp='0'; continue; }else if(fbit[j]=='0'&&ebit[j]=='0'){ rbit[rbit_index] = '0'; rbit_index--; temp='0'; continue; } } } if(temp=='1'){ rbit[rbit_index] = '1'; temp='0'; rbit_index--; } } void display(){ for(int i=0;i<=81;i++){ if(rbit[i]=='1'){ for(int j=i;j<=81;j++){ cout<<rbit[j]; } cout<<endl; return; } } cout<<'0'<<endl; } }; void cleanup(Case *d){ for(int i=0;i<=81;i++){ d->fbit[i]=d->ebit[i]=d->rbit[i]='0'; } } void main(){ Case *d; int i=0; cin>>i; d = (class Case *)malloc(i*sizeof(class Case)); for(int j=0;j<i;j++){ cleanup(&d[j]); d[j].init(); d[j].addition(); } for(j=0;j<i;j++){ cout<<j+1<<' '; d[j].display(); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator