Advertisement
SteelK

Untitled

Mar 10th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #define SIZE 101
  4.  
  5. using namespace std;
  6.  
  7. char *outchar(int in_number)
  8. {
  9.     char *outWord = new char [SIZE];
  10.     int snumber = in_number % 10;
  11.     switch (snumber)
  12.     {
  13.         case 0:
  14.             strcpy(outWord, "столов");
  15.         break;
  16.        
  17.         case 1:
  18.         {
  19.             if (in_number % 100 == 11)
  20.             {
  21.                 strcpy(outWord, "столов");
  22.             }
  23.             else
  24.                 strcpy(outWord, "стол");
  25.         }
  26.         break;
  27.        
  28.         case 2:
  29.         case 3:
  30.         case 4:
  31.         {
  32.             if ((in_number % 100 >= 12) && (in_number % 100 <= 14))
  33.             {
  34.                 strcpy(outWord, "столов");
  35.             }
  36.             else
  37.                 strcpy(outWord, "стола");
  38.         }
  39.         break;
  40.        
  41.         case 5:
  42.         case 6:
  43.         case 7:
  44.         case 8:
  45.         case 9:
  46.         {
  47.             strcpy(outWord, "столов");
  48.         }
  49.         break;
  50.     }
  51.     return outWord;
  52.     delete [] outWord;
  53. }
  54.  
  55.  
  56. int main()
  57. {
  58.     int number = 0;
  59.  
  60.     setlocale(0, "");
  61.  
  62.     cout << "Введите число\n";
  63.     cin >> number;
  64.     cout << number << " " << outchar(number)<< endl;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement