Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <map>
- #include <iomanip>
- using namespace std;
- int main() {
- const int n = 21;
- map<int, int> sum, size, pass;
- int id, group, score;
- for (int i = 0; i < n; i++) sum[i] = size[i] = pass[i] = 0;
- ifstream fin("itiran.csv");
- while (fin >> id >> group >> score) {
- sum[group] += score;
- size[group]++;
- if (score > 80) pass[group]++;
- }
- for (auto& e: sum) {
- if (e.first == 0) continue;
- if (size[e.first] == 0) {
- cout << e.first << ' ' << '-' << ' ' << '-' << ' ' << '-' << endl;
- continue;
- }
- cout << e.first << ' ' << size[e.first] << ' '
- << ((double) e.second) / size[e.first] << ' '
- << ((double) pass[e.first]) / size[e.first] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement