Advertisement
Alyks

Untitled

Oct 24th, 2019
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. vector<int> setMarks(int count) {
  7.     int mark = 0;
  8.     vector<int> arr(count);
  9.     for(int i = 0; i < count; i++){
  10.         cout << "Введите отметку\n";
  11.         cin >> mark;
  12.         if(mark < 1 || mark > 10) {
  13.             cout << "Отметки должны быть от 1 до 10 баллов\n";
  14.             i--;
  15.         } else
  16.             arr[i] = mark;
  17.     }
  18.     return arr;
  19. }
  20.  
  21. bool lessThan(vector<int> arr, int num) {
  22.     bool res = false;
  23.     for(int i = 0; i < arr.size(); i++){
  24.         if(arr[i] < num)
  25.             res = true;
  26.     }
  27.     return res;
  28. }
  29.  
  30. int main() {
  31.     cout << "Данная программа проверяет студента на успеваемость на основании его отметок\n" << endl;
  32.     int marksCount = 0;
  33.     cout << "Введите количество отметок \n";
  34.     cin >> marksCount;
  35.     vector<int> marks = setMarks(marksCount);
  36.     bool badStudent = lessThan(marks, 4);
  37.     if(badStudent)
  38.         cout << "Студент является неуспевающим";
  39.     else
  40.         cout << "Студент является успевающим";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement