Advertisement
horror04

c++ task

Oct 8th, 2021
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. 1.
  2.  
  3. #include <iostream>
  4. #include <cstdlib>
  5. using namespace std;
  6.  
  7. int age;
  8. int aver, a,b;
  9.  
  10. int avr(int age)
  11. {
  12.     a = age / 10;
  13.     b = age % 10;
  14.     aver = (a + b) / 2;
  15.     return aver;
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21.     setlocale(LC_ALL, "Russian");
  22.     cout << "Введите возраст: ";
  23.     cin >> age;
  24.     aver = avr(age);
  25.     cout << endl << "Сред. Арифм:" << aver << endl;
  26.  
  27.     system("pause");
  28.     return 0;
  29. }
  30.  
  31. 2.
  32.  
  33. #include <iostream>
  34. #include <cstdlib>
  35. using namespace std;
  36.  
  37. int a,b;
  38.  
  39. int max(int a, int b)
  40. {
  41.     if (a > b)
  42.         return a;
  43.     else
  44.         return b;
  45. }
  46.  
  47.  
  48. int main()
  49. {
  50.     setlocale(LC_ALL, "Russian");
  51.     cout << "Введите 2 числа: ";
  52.     cin >> a >> b;
  53.     cout << endl << max(a,b) << endl;
  54.  
  55.     system("pause");
  56.     return 0;
  57. }
  58.  
  59. 3.
  60.  
  61. #include <iostream>
  62. #include <cstdlib>
  63. using namespace std;
  64.  
  65. int input,a,b;
  66.  
  67. int obr(int input)
  68. {
  69.     a = input / 10;
  70.     b = input % 10;
  71.     return b * 10 + a;
  72.  
  73. }
  74.  
  75.  
  76. int main()
  77. {
  78.     setlocale(LC_ALL, "Russian");
  79.     cout << "Введите число: ";
  80.     cin >> input;
  81.     cout << endl << obr(input) << endl;
  82.  
  83.     system("pause");
  84.     return 0;
  85. }
  86.  
  87. 4.
  88.  
  89. #include <iostream>
  90. #include <cstdlib>
  91. using namespace std;
  92.  
  93. int a, b;
  94. int i = 0;
  95. string input;
  96. const char* glas = "AaEeIiOoUuYy";
  97.  
  98. string obr(string input)
  99. {
  100.     for (int i = 0; i < 12; i++)
  101.         if (input[0] == glas[i])
  102.         {
  103.        return "гласная";
  104.         }
  105.     else
  106.         return "не гласная";
  107.        
  108.  
  109.    
  110.  
  111. }
  112.  
  113.  
  114. int main()
  115. {
  116.     setlocale(LC_ALL, "Russian");
  117.     cin >> input;
  118.    
  119.     cout << endl << obr(input) << endl;
  120.  
  121.     system("pause");
  122.     return 0;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement