daily pastebin goal
17%
SHARE
TWEET

Homework extremel programming

a guest Feb 22nd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  main.cpp
  3. //  Project 2
  4. //
  5. //  Created by Артур Макушев on 21/02/2019.
  6. //  Copyright © 2019 Артур Макушев. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <map>
  11. #include <cstring>
  12. #include <cmath>
  13. using namespace std;
  14.  
  15. int multiplication (int a, int b, char c){
  16.     int result = a*b;
  17.     cout <<a << c << b <<" = ";
  18.     return result;
  19.    
  20. }
  21. int subtraction (int a, int b, char c){
  22.     int result = a-b;
  23.     cout <<a << c << b <<" = ";
  24.     return result;
  25. }
  26. int addition (int a, int b, char c){
  27.     int result = a+b;
  28.     cout <<a << c << b <<" = ";
  29.     return result;
  30. }
  31. int main() {
  32.         map <int, string> words;
  33.         //words [0] = "zero";
  34.         words [1] = "one";
  35.         words [2] = "two";
  36.         words [3] = "three";
  37.         words [4] = "four";
  38.         words [5] = "five";
  39.         words [6] = "six";
  40.         words [7] = "seven";
  41.         words [8] = "eight";
  42.         words [9] = "nine";
  43.         words [10] = "ten";
  44.         words [11] = "eleven";
  45.         words [12] = "twelve";
  46.         words [13] = "thirteen";
  47.         words [14] = "fourteen";
  48.         words [15] = "fifteen";
  49.         words [16] = "sixteen";
  50.         words [17] = "seventeen";
  51.         words [18] = "eighteen";
  52.         words [19] = "nineteen";
  53.         words [20] = "twenty";
  54.         words [30] = "thirty";
  55.         words [40] = "fourty";
  56.         words [50] = "fifty";
  57.         words [60] = "sixty";
  58.         words [70] = "seventy";
  59.         words [80] = "eighty";
  60.         words [90] = "ninety";
  61.         words [100] = "hundred";
  62.         words [1000] = "thousand";
  63.         words [1000000] = "million";
  64.         words [1000000000] = "billion";
  65.         int a,b,result,rememberR,rememberB,rememberC;
  66.         int n = 1;
  67.         int powerB;
  68.         int power = -1;
  69.         char c;
  70.     cout << "Введите числа и действие"<<endl;
  71.         cin >> a >> c >> b;
  72.     if (c == 43 ){
  73.        result =  addition(a,b,c);
  74.         rememberC = result;
  75.         while (result!=0){
  76.             result = result/10;
  77.             power+=1;
  78.         }
  79.         result = rememberC;
  80.         powerB = power%3;
  81.         power = power-powerB;
  82.         cout << result<<endl;
  83.         while (power>=0){
  84.         if (result >= pow(10,power)){
  85.             result = result / pow (10,power);
  86.         }
  87.         rememberR = result%100;
  88.        
  89.         if (result >=100){
  90.         cout << words[result/100]<<" ";
  91.         cout << words [100]<<" ";
  92.         }
  93.         result = rememberR;
  94.         if (result > 20&& result <100){
  95.             cout << words[(result/10)*10]<<" ";
  96.             cout << words[result%10]<<" ";
  97.         }
  98.         if (result < 21){
  99.             cout << words[result]<<" ";
  100.         }
  101.             if (power!=0){
  102.                 cout << words[pow(10,power)]<<" ";}
  103.             rememberR = 0;
  104.             n=0;
  105.             while (rememberR!=power){
  106.                 rememberR+=1;
  107.                 n = n *10;
  108.             }
  109.            
  110.         power = power-3;
  111.         result = rememberC;
  112.        
  113.             result = result%n;
  114.         }
  115.        
  116.        
  117.        
  118.     }
  119.        
  120.     if (c == 42 ){
  121.         result =multiplication(a,b,c);
  122.         cout << result<<endl;
  123.         rememberC = result;
  124.         while (result!=0){
  125.             result = result/10;
  126.             power+=1;
  127.         }
  128.         result = rememberC;
  129.         powerB = power%3;
  130.         power = power-powerB;
  131.         cout << result<<endl;
  132.         while (power>=0&&result!=0){
  133.             rememberC;
  134.             if (result >= pow(10,power)){
  135.                 result = result / pow (10,power);
  136.             }
  137.             rememberR = result%100;
  138.            
  139.             if (result >=100){
  140.                 cout << words[result/100]<<" ";
  141.                 cout << words [100]<<" ";
  142.             }
  143.             result = rememberR;
  144.             if (result > 20&& result <100){
  145.                 cout << words[(result/10)*10]<<" ";
  146.                 cout << words[result%10]<<" ";
  147.             }
  148.             if (result < 21){
  149.                 cout << words[result]<<" ";
  150.             }
  151.             if (power!=0){
  152.                 cout << words[pow(10,power)]<<" ";}
  153.             rememberR = 0;
  154.            
  155.             while (rememberR!=power){
  156.                 rememberR+=1;
  157.                 n = n *10;
  158.             }
  159.            
  160.             power = power-3;
  161.             result = rememberC;
  162.             rememberC = (rememberC/n)*n;
  163.            
  164.             result = result- rememberC;
  165.             n=1;
  166.            
  167.            // cout << endl << "result = "<< result<<endl;
  168.         }
  169.        
  170.        
  171.        
  172.     }
  173.     if (c == 45 ){
  174.         result =subtraction(a,b,c);
  175.         cout << result<<endl;
  176.         rememberC = result;
  177.         while (result!=0){
  178.             result = result/10;
  179.             power+=1;
  180.         }
  181.         result = rememberC;
  182.         powerB = power%3;
  183.         power = power-powerB;
  184.         cout << result<<endl;
  185.         while (power>=0){
  186.             if (result >= pow(10,power)){
  187.                 result = result / pow (10,power);
  188.             }
  189.             rememberR = result%100;
  190.            
  191.             if (result >=100){
  192.                 cout << words[result/100]<<" ";
  193.                 cout << words [100]<<" ";
  194.             }
  195.             result = rememberR;
  196.             if (result > 20&& result <100){
  197.                 cout << words[(result/10)*10]<<" ";
  198.                 cout << words[result%10]<<" ";
  199.             }
  200.             if (result < 21){
  201.                 cout << words[result]<<" ";
  202.             }
  203.             if (power!=0){
  204.                 cout << words[pow(10,power)]<<" ";}
  205.             rememberR = 0;
  206.             while (rememberR!=power){
  207.                 rememberR+=1;
  208.                 n = n *10;
  209.             }
  210.            
  211.             power = power-3;
  212.             result = rememberC;
  213.            
  214.             result = result%n;
  215.         }
  216.        
  217.        
  218.        
  219.     }
  220.    
  221.     return 0;
  222. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top