Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int A[10],B[10];
- int main()
- {
- int a,b;
- cin>>a>>b;
- int x=a,n=0,m=0;
- while(x)
- A[n++]=x%10,x/=10;
- --n;
- x=b;
- while(x)
- B[m++]=x%10,x/=10;
- int T=0;
- --m;
- if(m>n) /// Daca b are mai multe cifre decat a
- for(int i=n;i<m;++i) /// adaugam zerouri in fata
- A[i]=0;
- else /// a are mai multe cifre decat b
- for(int i=n;i<m;++i)
- B[i]=0;
- for(int i=0;i<n;++i)
- {
- A[i]+=B[i]+T;
- T=A[i]/10;
- if(T)
- {
- cout<<"Gigel nu stie! El poate cumpara "<<1ULL*a+1ULL*b<<" bomboane!\n";
- return 0;
- }
- A[i]%=10;
- }
- if(T)
- cout<<"Gigel nu stie! El poate cumpara "<<1ULL*a+1ULL*b<<" bomboane!\n";
- else
- cout<<"Gigel stie!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement