Advertisement
Guest User

Untitled

a guest
Apr 14th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.32 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char input;
  4. int X;
  5. int buffer[16];
  6. int i = 0;
  7. int y = 0;
  8. int tmp;
  9. int tmp_va;
  10. int output = 0;
  11. int power[5] = {10000,1000,100,10,0};
  12.  
  13.  
  14. int main()
  15. {
  16.   do
  17.   {
  18.     input = getchar();
  19.  
  20.  
  21.  
  22. if(input == 0x0A){
  23.   putchar(0x0A);
  24.  
  25.     if(buffer[i] > 0){
  26.       i++;
  27.  
  28.     }
  29.     buffer[i] = X;
  30.  
  31.   tmp = 0;
  32.   }
  33.  
  34.  
  35.  
  36.       else if(input == 0x2B){
  37.         putchar(0x2B);
  38.         putchar(0x0A);
  39.         X = buffer[i] + X;
  40.         buffer[i] = 0;
  41.  
  42.  
  43.         tmp = X;
  44.         y = 0;
  45.           do {
  46.             output = 0;
  47.               while(tmp >= power[y]){
  48.                 tmp = tmp - power[y];
  49.                 output++;
  50.              }
  51.              if(tmp < X){
  52.                output = output + 0x30;
  53.                putchar(output);
  54.              }
  55.              y++;
  56.          } while(power[y] > 0);
  57.  
  58.  
  59.          if(tmp >= 0){
  60.           tmp = tmp + 0x30;
  61.           putchar(tmp);
  62.         }
  63.  
  64.         tmp = 0;
  65.  
  66.  
  67.         if(i > 0){
  68.           i--;
  69.         }
  70.      }
  71.  
  72.       else{
  73.         putchar(input);
  74.         if(tmp == 0){
  75.           X = input - 0x30;
  76.         }
  77.         else{
  78.           tmp_va = X;
  79.           X = X << 3;
  80.           tmp_va = tmp_va << 1;
  81.           X = X + tmp_va;
  82.           X = X + input - 0x30;
  83.         }
  84.         tmp = 1;
  85.       }
  86.     } while (input != EOF);
  87.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement