• Помогите написать программу. На языке С++
    Тема была классы в C++
    Задание и пример программы во вложении.
    Нужно по примеру сделать задание.

    question img
    question img

Ответы 3

  • сбилось форматирование, сейчас исправлю
  • готово
  • // ConsoleApplication4.cpp: определяет точку входа для консольного приложения.//#include "stdafx.h"#include <iostream>#include <string>using namespace std;class stud {public:void setname(string sname){name = sname;}string getname(){return name;}string getsurname(){return surname;}void setsurname(string ssurname){surname = ssurname;}void setscore(int sc[]){for (int i = 0; i<10; i++) score[i] = sc[i];}float getsr(){float sum = 0;for (int i = 0; i<10; i++) sum += (float)score[i];return sum / 10;}void showmyself(){cout << "Студент: " << name << " " << surname << endl;cout << "Имеет 10 текущих оценок: ";for (int i = 0; i < 10; i++) cout << score[i] << " ";cout << "" << endl;cout << "Его средний балл: " << getsr() << endl;}private:string name;string surname;int score[10];};int main(int acgc, char* argv[]){setlocale(LC_ALL, "rus");stud student1;int score[10];string name, surname;cout << "Введите имя студента: "<<endl;getline(cin, name);cout << "Введите фамилию студента: " << endl;getline(cin, surname);cout << "введите 10 текущих оценок через пробел: " << endl;for (int i = 0; i<10; i++) cin >> score[i];student1.setname(name);student1.setsurname(surname);student1.setscore(score);student1.showmyself();system("pause");}
    answer img
    • Автор:

      josiah24
    • 5 лет назад
    • 0
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years