x2311

Untitled

Jan 12th, 2022
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. bool yfy(int nam, int n);
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n = 3;
  9.     int nam = 0;
  10.     for (int i = 0; i < n; ++i) {
  11.         cout << endl;
  12.         cout << i+1;
  13.         cout << " nam ";
  14.         cout << ": ";
  15.         int t;
  16.         cin >> t;
  17.         nam += t;
  18.     }
  19.     cout << endl;
  20.     cout  << "sum: ";
  21.     cout<< nam;
  22.  
  23.     if (yfy(nam, n)) {
  24.         cout << endl;
  25.         cout << "+ nam";
  26.     } else {
  27.         cout << endl;
  28.         cout << "- nam";
  29.     }
  30.  
  31. }
  32.  
  33. bool yfy(int nam, int n) {
  34.     if (nam == n) {
  35.         return true;
  36.     }
  37.     return false;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment