x2311

Untitled

Dec 21st, 2021
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct base {
  6.     string name;
  7.     double result{};
  8. };
  9.  
  10. const int NUMBER_OF_OUTPUT = 3;
  11. const int SIZE = 4;
  12.  
  13. int main() {
  14.     base b[SIZE];
  15.     for (auto &i: b) {
  16.         cout << "Enter name :" << endl;
  17.         cin >> i.name;
  18.         cout << "Enter date :" << endl;
  19.         cin >> i.result;
  20.         cout << endl;
  21.     }
  22.  
  23.     for (int i = 0, t = -1; i < NUMBER_OF_OUTPUT; ++i) {
  24.         for (int j = 0; j < SIZE; ++j) {
  25.             if (t == -1) {
  26.                 if (b[j].result != 0) {
  27.                     t = j;
  28.  
  29.                 } else {
  30.                     continue;
  31.                 }
  32.             }
  33.             if (b[t].result >= b[j].result && b[j].result != 0) {
  34.                 t = j;
  35.             }
  36.         }
  37.         cout << i + 1 << ") " << b[t].name << "\t" << b[t].result << endl;
  38.         b[t].result = 0;
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment