Advertisement
Kaloyankerr

SchoolHW №3

Mar 19th, 2021 (edited)
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. Задача 1)
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. int main()  
  7. {  
  8.     string answear;
  9.    
  10.     do {
  11.         cout << "Have you watched Justice League?[Y; N]";
  12.         cin >> answear;
  13.     }
  14.     while (answear != "Y" || answear != "N");
  15.    
  16.     if (answear == "Y") {
  17.         cout << "Don't SPOIL IT!";
  18.     } else {
  19.         cout << "Let's watch it together!";
  20.     }
  21.     return 0;  
  22. }  
  23. ========================================================
  24. Задача 2)
  25. #include <iostream>
  26. using namespace std;
  27.  
  28.  
  29. int main()  
  30. {  
  31.     int n, sum, count;
  32.     count = 0;
  33.    
  34.     cout << "Enter n: ";
  35.     cin >> n;
  36.    
  37.     do {
  38.        
  39.         sum += count;
  40.         count++;
  41.     }
  42.     while (count <= n);
  43.    
  44.     cout << "The result is: " << sum;
  45.    
  46.     return 0;  
  47. }  
  48. ========================================================
  49. Задача 3)
  50. #include <iostream>
  51. using namespace std;
  52.  
  53.  
  54. int main()  
  55. {  
  56.     int n, counter, count_of_possitive;
  57.    
  58.     count_of_possitive = 0;
  59.     counter = 0;
  60.    
  61.     cout << "Enter n: ";
  62.     cin >> n;
  63.    
  64.     do {
  65.         if (counter % 2 == 0 && counter > 0){
  66.             count_of_possitive++;
  67.             cout << "Number " << counter << " is possitive!\n";
  68.         }
  69.         counter++;
  70.     }
  71.     while (counter < n);
  72.    
  73.     cout << "The possitive numbers are: " << count_of_possitive;
  74.    
  75.     return 0;  
  76. }
  77. ========================================================
  78. Задача 4)
  79. #include <iostream>
  80. #include <cmath>
  81. using namespace std;
  82.  
  83.  
  84. int main()  
  85. {  
  86.     int x, y, power = 1;
  87.     cin >> x >> y;
  88.    
  89.     do {
  90.         cout << power << " is a possitive power for a x\n";
  91.         power++;
  92.     } while (pow(x, power) < y);
  93.    
  94.     return 0;  
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement