Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- const int maxN = 11;
- int marks[11];
- double grades[11];
- void get_grade (int idx) {
- if (marks[idx] >= 80) {
- grades[idx] = 4.0;
- } else if (marks[idx] >= 70) {
- grades[idx] = 3.5;
- } else if (marks[idx] >= 60) {
- grades[idx] = 3.0;
- } else if (marks[idx] >= 50) {
- grades[idx] = 2.5;
- } else if (marks[idx] >= 40) {
- grades[idx] = 2.0;
- } else {
- grades[idx] = 0.0;
- }
- }
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- for (int i = 1; i < maxN; ++i) marks[i] = rand() % 100 + 1;
- //~ marks[1] = 100;
- //~ marks[2] = 200;
- for (int i = 1; i < maxN; ++i) {
- get_grade(i);
- }
- double sum = 0;
- for (int i = 1; i < maxN; ++i) {
- sum += grades[i];
- }
- cout << sum / 10.0 << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement