Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stack>
- #include <iostream>
- #include <stdio.h>
- #include <string>
- #include <math.h>
- using namespace std;
- int main()
- {
- int think1=0;
- int think2=0;
- int a;
- int b;
- stack<int> keep;
- string in1;
- cin>>in1;
- a=in1.length();
- stack<int> keep2;
- string in2;
- cin>>in2;
- b=in2.length();
- stack<int> show;
- int run1=0;
- while(in1[run1]!=NULL)
- {
- keep.push(in1[run1]-48);
- run1=run1+1;
- }
- int run2=0;
- while(in2[run2]!=NULL)
- {
- keep2.push(in2[run2]-48);
- run2=run2+1;
- }
- while(true)
- {
- if(!keep.empty())
- {
- think1=keep.top();
- keep.pop();
- }
- if(!keep2.empty())
- {
- think2=keep2.top();
- keep.pop();
- }
- if(think1+think2>=10)
- {
- if(keep.empty())
- {
- show.push(think1+think2);
- break;
- }
- else if(a>b)
- {
- show.push((think1+think2)%10);
- int use=keep.top()+1;
- keep.pop();
- keep.push(use);
- }
- else
- {
- show.push((think1+think2)%10);
- int use=keep2.top()+1;
- keep2.pop();
- keep2.push(use);
- }
- }
- else if(think1+think2<10)
- {
- show.push(think1+think2);
- }
- }
- cout<<"as";
- while(!show.empty())
- {
- cout<<show.top();
- show.pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement