Petro_zzz

311_3101

Feb 2nd, 2024
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void age_control() {
  6. int age;
  7. cout << "How old are you?";
  8. cin >> age;
  9.  
  10. if (age >= 18) {
  11. cout << "admited" << endl;
  12. }
  13. else {
  14. cout << "denied" << endl;
  15. }
  16. }
  17.  
  18. void is_even() {
  19. int k;
  20. cout << "Enter number "; cin >> k;
  21.  
  22. if (k % 2) {
  23. cout << k << " is even.\n";
  24. }
  25. else {
  26. cout << k << " is odd.\n";
  27. }
  28. }
  29.  
  30. void check_number() {
  31. int k;
  32. cout << "Enter number "; cin >> k;
  33. if (k == 0) {
  34. cout << k << " is zero.\n";
  35. }
  36. else if (k > 0) {
  37. cout << k << " is positive.\n";
  38. }
  39. else {
  40. cout << k << " is negative.\n";
  41. }
  42. }
  43.  
  44. void is_ring() {
  45. double r1 = 1;
  46. double r2 = 2;
  47.  
  48. double x = 1.5;
  49. double y = 1.2;
  50.  
  51. double dist = pow(x, 2) + pow(y, 2);
  52.  
  53. if ((dist > r1 * r1) && (dist <= r2 * r2)) {
  54. cout << "Bingo\n";
  55. }
  56. else {
  57. cout << "Milk\n";
  58. }
  59. }
  60.  
  61. void is_teenager() {
  62. const int min_age = 14;
  63. const int max_age = 18;
  64.  
  65. int age;
  66. cout << "Age? "; cin >> age;
  67.  
  68. // && - and
  69. // || - or
  70. // !  - not
  71. //    - xor
  72.  
  73. if ((min_age <= age) && (age <= max_age)) {
  74. cout << "Yes" << endl;
  75. }
  76. else {
  77. cout << "No" << endl;
  78. }
  79. }
  80.  
  81.  
  82.  
  83. int main() {
  84. setlocale(LC_ALL, "russian");
  85. //age_control();
  86. //is_even();
  87. //check_number();
  88. //is_ring();
  89. int x = (x == 0)  ? -1 : 6;
  90. cout << ((x == 0) ?
  91. "zero " : ((x > 0) ?
  92. "positive " :
  93. "negative "));
  94. cout << endl;
  95. system("pause");
  96. return 0;
  97. }
  98.  
Add Comment
Please, Sign In to add comment