私はC++を勉強していて、C++で構造「Student」を作成してそれを操作する必要があります(Microsoft Visual C++ 2010 Expressを使用しています)Student.cppファイル
を作成しました
#include "stdafx.h"
using namespace std;
const int num = 5;
struct Student {
char name[30];
int groupNumber;
int progress[num];
};
そしてそれは私のプログラムです
#include "stdafx.h"
#include "Student.cpp"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
setlocale (LC_ALL, "Russian");
srand((unsigned)time(NULL));
int n;
cout << "Введите количество студентов в группе n = ";
cin >> n;
Student * Group = new Student[n];
for (int i = 0; i < n; ++i)
{
cout << "Введите ФИО: ";
cin >> Group[i].name;
Group[i].groupNumber = rand()%5 + 1;
for (int j = 0; j < num; ++j)
{
Group[i].progress[j] = rand()%5 + 2;
}
}
for (int i = 0; i < n; ++i)
{
int sum = 0;
for (int j = 0; j < num; ++j)
{
sum += Group[i].progress[j];
}
double count = (double)sum/5;
if (count < 4) continue;
cout << "\n\n" << Group[i].name << "\nГруппа: " << Group[i].groupNumber << "\nСредний бал: " << count;
}
cout << "\n\n";
delete [] Group;
system("PAUSE");
return 0;
}
しかし、スペースバーで名前を入力しようとすると (たとえば、1 人の学生の姓と名)、サークルが 1 ステップ抜けたようなエラーが発生しました
string
名前に使ってみた
string name
しかし、問題は同じままです。
何が問題で、どうすれば修正できますか?