#include #include #include #include int fib[40]; void vytvor_fib() { fib[0]=1; fib[1]=2; for(int i=2;i<40;i++) { fib[i]=fib[i-1]+fib[i-2]; } //for } int fib_c(char vstup[],int delka) { int c=0; for(int i=0,j=delka-1 ; j>=0 ; i++,j--) { if(vstup[i]=='1') { c+=fib[j]; } //if } //for return c; } char *c_fib(long c) { char *pom = new char[50]; int j; do { j = 0; for(int i=39;i>=0;i--) { if(c-fib[i]>=0) { c-=fib[i]; pom[j++]='1'; } //if else { pom[j++]='0'; } //else } //for } while(c>0); pom[j] = 0; return pom; } int main() { while (!cin.eof()) { char v1[50],v2[50],*vn1,*vn2,*v3,*pom1,*pom2,*pom3; long c1,c2,c3; int d_v3,d_v1,d_v2; vytvor_fib(); cin >> v1 >> v2; if (strlen(v1) == 0) return 0; c1=fib_c(v1,strlen(v1)); c2=fib_c(v2,strlen(v2)); c3=c1+c2; vn1=c_fib(c1); if ((pom1=strchr(vn1,'1')) == NULL) { pom1 = new char[2]; pom1[0] = '0'; pom1[1] = 0; } vn2=c_fib(c2); if ((pom2=strchr(vn2,'1')) == NULL) { pom2 = new char[2]; pom2[0] = '0'; pom2[1] = 0; } v3=c_fib(c3); if ((pom3=strchr(v3,'1')) == NULL) { pom3 = new char[2]; pom3[0] = '0'; pom3[1] = 0; } d_v3=strlen(pom3); d_v1=strlen(pom1); d_v2=strlen(pom2); for(int i=0;i<(d_v3+2-d_v1);i++) { cout << " "; } //for cout << pom1 << endl << "+ "; for(int i=0;i<(d_v3-d_v2);i++) { cout << " "; } //for cout << pom2 << endl << " "; for(int i=0;i<(d_v3);i++) { cout << "-"; } //for cout << endl << " " << pom3 << endl << endl; delete vn1; delete vn2; delete v3; } return 0; }