Advertisement
newb_ie

Untitled

Oct 28th, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. const int maxN = 11;
  5. int marks[11];
  6. double grades[11];
  7.  
  8. void get_grade (int idx) {
  9. if (marks[idx] >= 80) {
  10. grades[idx] = 4.0;
  11. } else if (marks[idx] >= 70) {
  12. grades[idx] = 3.5;
  13. } else if (marks[idx] >= 60) {
  14. grades[idx] = 3.0;
  15. } else if (marks[idx] >= 50) {
  16. grades[idx] = 2.5;
  17. } else if (marks[idx] >= 40) {
  18. grades[idx] = 2.0;
  19. } else {
  20. grades[idx] = 0.0;
  21. }
  22. }
  23.  
  24. int main () {
  25. ios::sync_with_stdio(false);
  26. cin.tie(nullptr);
  27. cout.tie(nullptr);
  28. for (int i = 1; i < maxN; ++i) marks[i] = rand() % 100 + 1;
  29. //~ marks[1] = 100;
  30. //~ marks[2] = 200;
  31. for (int i = 1; i < maxN; ++i) {
  32. get_grade(i);
  33. }
  34. double sum = 0;
  35. for (int i = 1; i < maxN; ++i) {
  36. sum += grades[i];
  37. }
  38. cout << sum / 10.0 << '\n';
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement