Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct base {
- string name;
- double result{};
- };
- const int NUMBER_OF_OUTPUT = 3;
- const int SIZE = 4;
- int main() {
- base b[SIZE];
- for (auto &i: b) {
- cout << "Enter name :" << endl;
- cin >> i.name;
- cout << "Enter date :" << endl;
- cin >> i.result;
- cout << endl;
- }
- for (int i = 0, t = -1; i < NUMBER_OF_OUTPUT; ++i) {
- for (int j = 0; j < SIZE; ++j) {
- if (t == -1) {
- if (b[j].result != 0) {
- t = j;
- } else {
- continue;
- }
- }
- if (b[t].result >= b[j].result && b[j].result != 0) {
- t = j;
- }
- }
- cout << i + 1 << ") " << b[t].name << "\t" << b[t].result << endl;
- b[t].result = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment