HII GUYS THIS IS ONE OF THE EASY PROBLEM FOR BEGINNERS........ the only thing that u have to do is simply follow the questions......... The one thing that cause me some wrong answer take care of (0)
#include<bits/stdc++.h> using namespace std; int main() { char str[10000]; while(1) { scanf("%s",str); if(strcmp(str,"BYE")==0) break; long long int i=0,count,count2; // printf("%s\n",str); count=0; char num1[10000]; char arr[10]; while(str[i]!='+') { arr[0]=str[i]; arr[1]=str[i+1]; arr[2]=str[i+2]; arr[3]='\0'; i=i+3; if(!strcmp(arr,"063")) { num1[count++]='0'; continue; } if(!strcmp(arr,"010")) { num1[count++]='1'; continue; } if(!strcmp(arr,"093")) { num1[count++]='2'; continue; } if(!strcmp(arr,"079")) { num1[count++]='3'; continue; } if(!strcmp(arr,"106")) { num1[count++]='4'; continue; } if(!strcmp(arr,"103")) { num1[count++]='5'; continue; } if(!strcmp(arr,"119")) { num1[count++]='6'; continue; } if(!strcmp(arr,"011")) { num1[count++]='7'; continue; } if(!strcmp(arr,"127")) { num1[count++]='8'; continue; } if(!strcmp(arr,"107")) { num1[count++]='9'; continue; } } num1[count]='\0'; i++; count2=0; char num2[10000]; while(str[i]!='=') { arr[0]=str[i]; arr[1]=str[i+1]; arr[2]=str[i+2]; arr[3]='\0'; i=i+3; if(!strcmp(arr,"063")) { num2[count2++]='0'; continue; } if(!strcmp(arr,"010")) { num2[count2++]='1'; continue; } if(!strcmp(arr,"093")) { num2[count2++]='2'; continue; } if(!strcmp(arr,"079")) { num2[count2++]='3'; continue; } if(!strcmp(arr,"106")) { num2[count2++]='4'; continue; } if(!strcmp(arr,"103")) { num2[count2++]='5'; continue; } if(!strcmp(arr,"119")) { num2[count2++]='6'; continue; } if(!strcmp(arr,"011")) { num2[count2++]='7'; continue; } if(!strcmp(arr,"127")) { num2[count2++]='8'; continue; } if(!strcmp(arr,"107")) { num2[count2++]='9'; continue; } } num2[count2]='\0'; long long int x=0,y=0; for(i=0;i<count;i++) x=x*10+(num1[i]-'0'); for(i=0;i<count2;i++) y=y*10+(num2[i]-'0'); long long int ans; ans=x+y; //printf("ans=%lld\n",ans); char dev[10000]; long long int p=0; while(ans) { x=ans%10; ans/=10; if(x==0) { dev[p++]='3'; dev[p++]='6'; dev[p++]='0'; continue; } if(x==1) { dev[p++]='0'; dev[p++]='1'; dev[p++]='0'; continue; } if(x==2) { dev[p++]='3'; dev[p++]='9'; dev[p++]='0'; continue; } if(x==3) { dev[p++]='9'; dev[p++]='7'; dev[p++]='0'; continue; } if(x==4) { dev[p++]='6'; dev[p++]='0'; dev[p++]='1'; continue; } if(x==5) { dev[p++]='3'; dev[p++]='0'; dev[p++]='1'; continue; } if(x==6) { dev[p++]='9'; dev[p++]='1'; dev[p++]='1'; continue; } if(x==7) { dev[p++]='1'; dev[p++]='1'; dev[p++]='0'; continue; } if(x==8) { dev[p++]='7'; dev[p++]='2'; dev[p++]='1'; continue; } if(x==9) { dev[p++]='7'; dev[p++]='0'; dev[p++]='1'; continue; } } printf("%s",str); for(i=p-1;i>=0;i--) printf("%c",dev[i]); printf("\n"); } return 0; }
No comments:
Post a Comment