@lion221133

Программа записи/чтения данных векторов не работает, в чем дело?

Программа должна записывать оценки/баллы по двум предметам, но в конечном итоге не выполняет этих функций. Я еще не освоился в c++ и stl, не знаю, что сделал не так.
Состоит из двух файлов: main.cpp
#include <iostream>
#include "student .h"
#include <string>
using namespace std;
int main(int argc, char** argv) {
    student i;
    string t;
    cout<<"rewrite or watch? ";
    cin>>t;
    if (t=="rewrite"){
    i.i();
    };
    if(t=="watch") {
    i.n();
    };
	return 0;
};

и student.h:
#include <iostream>
#include <vector>
using namespace std;
class student{
	public:
 void i(){
 	int a;
 	cout<<"Russian-1,Math-2:";
 	cin>>a;
 	if (a==1){
 		cout<<"How many scores? ";
 		int b;
 		cin>>b;
 		cout<<"Enter:";
 		for (int i=1;i<=b;){

 			cin >> rus[rus1];
 			rus1++;
            i++;
 		};
 	};
 		if (a==2){
 		cout<<"How many scores? ";
 		int b;
 		cin>>b;
 		cout<<"Enter:";
 		for (int i=1;i<=b;){
 			cin>>math[math1];
 			math1++;
 			i++;
 		};
 	};
 };
 void n(){
  	int c;
 	cout<<"Russian-1,Math-2:";
 	cin>>c;
    if (c==1){
        for (int i = 0; i<rus1;){
            cout << rus[i];
            i++;
        };
    };
    if (c==2){
        for (int i=0;i<math1;){
            cout << math[i];
            i++;
        };
    };
 };




    private:
vector<int> math ;
vector<int> rus ;
int math1 = 0;
int rus1 = 0;
    };
  • Вопрос задан
  • 105 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы