Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.  
  9. int a,b,pre=0;
  10. cin>>a>>b;
  11. int golem;
  12. if (a<b) golem=b;
  13. else golem=a;
  14. vector<int>aniza;
  15. vector<int>bniza;
  16. while (golem!=0){
  17. aniza.push_back(a%10);
  18. bniza.push_back(b%10);
  19. a/=10; b/=10;golem/=10;
  20. }
  21. int o;
  22. if (aniza.size()>bniza.size())
  23. o=aniza.size();
  24. else
  25. o=bniza.size();
  26.  
  27. int sum[o];
  28. sum[o]={0};
  29.  
  30. for (int i=0;i<o;i++)
  31. {
  32. sum[i]+=aniza[i]+bniza[i];
  33.  
  34. if (sum[i]>9) {pre++;sum[i+1]+=sum[i]/10;}
  35. }
  36.  
  37. cout<< pre;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement