Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- //freopen ("10035.in", "r", stdin);
- //freopen ("10035.out", "w", stdout);
- string str1, str2;
- int a, b, i, arr1[12]={0}, arr2[12]={0}, count = 0, size;
- while (cin >> str1 >> str2)
- {
- if (str1 == "0" && str2 == "0")
- {
- cout<<endl;
- break;
- }
- else
- {
- for (i = 10; i > 10 - str1.size(); i--)
- {
- arr1[i] = str1[10-i] - '0';
- }
- for (i = 10; i >10- str2.size(); i--)
- {
- arr2[i] = str2[10 - i] - '0';
- }
- size = str1.size();
- if (size < str2.size())
- {
- size = str2.size();
- }
- count=0;
- for (int k = 0; k <10; k++)
- {
- if (arr1[k] + arr2[k] > 9)
- {
- count = count + 1;
- arr1[k + 1]=arr1[k+1]+1;
- }
- }
- if (count == 1)
- {
- cout << "1 carry operation." << endl;
- }
- else if(count == 0)
- {
- cout<<"No carry operation."<<endl;
- }
- else
- {
- cout << count << " carry operations." << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement