Advertisement
apl-mhd

uvaB

Feb 9th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <cstdio>
  2. #include <string>
  3. #include <cstring>
  4. #include <sstream>
  5. #include <iostream>
  6. #include <iostream>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. int reverse(string number){
  12.    
  13.    
  14.         int i, j;
  15.         char temp;
  16.         i=0;
  17.         j= number.size()-1;
  18.        
  19.        
  20.         while(i<j){
  21.             temp = number[i];
  22.             number[i]=number[j];
  23.             number[j] = temp;
  24.            
  25.             i++;
  26.             j--;
  27.            
  28.             }
  29.            
  30.     return  atoi(number.c_str());
  31.     }
  32.  
  33. int main(int argc, char **argv)
  34. {
  35.    
  36.    
  37.     stringstream m;
  38.    
  39.     int t,x,y,sum,reminder;
  40.    
  41.     string a,b,first;  
  42.     cin>>t;
  43.    
  44.     while(t--){
  45.         sum=0;
  46.         reminder=0;
  47.         cin>>a;
  48.         cin>>b;
  49.        
  50.         x = reverse(a);
  51.         y = reverse(b);
  52.        
  53.         sum = x+y;
  54.        
  55.         //m<<sum;
  56.          //first = m.str();
  57.          
  58.          while(sum != 0 ){
  59.              
  60.              //reminder = sum % 10;
  61.              
  62.               reminder = reminder*10+(sum%10);
  63.              
  64.            
  65.              
  66.              sum /=10;
  67.              
  68.              }
  69.              
  70.             printf("%d",reminder);
  71.          
  72.        
  73.          
  74.         // printf("%c%c%c",first[0],first[1],first[2]);
  75.        
  76.         //printf("%d\n", reverse(first));
  77.        
  78.         //m<<0;
  79.         //string s = to_string(sum);
  80.         //string str = string(intStr);
  81.            
  82.         //cout<<str;
  83.        
  84.         }
  85.    
  86.    
  87.    
  88.     return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement