Advertisement
Guest User

where the fuck is error

a guest
Mar 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.13 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #pragma warning (disable:4996)
  5.  
  6. int main()
  7. {
  8.   char num1, num2;
  9.   int opchar;
  10.   int ch1, ch2;
  11.   int ans;
  12.   int opOK;
  13.  
  14.     do{
  15.         ch1 = ch2 = num1 = num2 = ans = 0;
  16.  
  17.         do{
  18.         num1 = getchar();
  19.         switch(num1)
  20.         {
  21.         case 'M':
  22.         case 'm':
  23.             ch1 += 1000;
  24.             break;
  25.         case 'D':
  26.         case 'd':
  27.             ch1 += 500;
  28.             break;
  29.         case 'C':
  30.         case 'c':
  31.             ch1 += 100;
  32.             break;
  33.         case 'L':
  34.         case 'l':
  35.             ch1 += 50;
  36.             break;
  37.         case 'X':
  38.         case 'x':
  39.             ch1 += 10;
  40.             break;
  41.         case 'V':
  42.         case 'v':
  43.             ch1 += 5;
  44.             break;
  45.         case 'I':
  46.         case 'i':
  47.             ch1 =+ 1;
  48.             break;
  49.         default:
  50.             break;
  51.         }
  52.     }
  53.   while(num1 != 'Q' && num1 !='q');
  54.  
  55.     do{
  56.         num2 = getchar();
  57.         switch(num2)
  58.         {
  59.         case 'M':
  60.         case 'm':
  61.             ch1 += 1000;
  62.             break;
  63.         case 'D':
  64.         case 'd':
  65.             ch1 += 500;
  66.             break;
  67.         case 'C':
  68.         case 'c':
  69.             ch1 += 100;
  70.             break;
  71.         case 'L':
  72.         case 'l':
  73.             ch1 += 50;
  74.             break;
  75.         case 'X':
  76.         case 'x':
  77.             ch1 += 10;
  78.             break;
  79.         case 'V':
  80.         case 'v':
  81.             ch1 += 5;
  82.             break;
  83.         case 'I':
  84.         case 'i':
  85.             ch1 =+ 1;
  86.             break;
  87.         default:
  88.             break;
  89.         }
  90.     }
  91.   while(num2 != 'Q' && num2 !='q');
  92.  
  93.     do{
  94.         opchar = getchar();
  95.  
  96.         switch(opchar)
  97.         {
  98.         case '+':
  99.             ans = ch1 + ch2;
  100.             opOK = true;
  101.             break;
  102.         case '-':
  103.             ans = ch1 - ch2;
  104.             opOK = true;
  105.             break;
  106.         case '*':
  107.             ans = ch1 * ch2;
  108.             opOK = true;
  109.             break;
  110.         case '/':
  111.             if(num2 ==0)
  112.             {
  113.                 printf("\n-\n");
  114.                 opOK = false;
  115.                 break;
  116.             }
  117.             else
  118.             {
  119.                 ans = ch1 / ch2;
  120.                 opOK = true;
  121.                 break;
  122.             }
  123. defalut:
  124.             printf("-\n");
  125.             opOK = false;
  126.         }
  127.     }
  128.   while(opOK != true);
  129.   printf("\n%d\n", ans);
  130.  
  131.     if(ans < 0)
  132.     {
  133.         printf("-");
  134.         ans *= -1;
  135.     }
  136.     while(ans >= 1000)
  137.     {
  138.         printf("M");
  139.         ans -= 1000;
  140.     }
  141.     while(ans >= 500)
  142.     {
  143.         printf("D");
  144.         ans -= 500;
  145.     }
  146.     while(ans >= 100)
  147.     {
  148.         printf("C");
  149.         ans -= 100;
  150.     }
  151.     while(ans >= 50)
  152.     {
  153.         printf("L");
  154.         ans -= 50;
  155.     }
  156.     while(ans >= 10)
  157.     {
  158.         printf("X");
  159.         ans -= 10;
  160.     }
  161.     while(ans>= 5)
  162.     {
  163.         printf("V");
  164.         ans -= 5;
  165.     }
  166.     while(ans >= 1)
  167.     {
  168.         printf("I");
  169.         ans -= 1;
  170.     }
  171.  
  172.     }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement