所以我最近遇到了以下代码:
struct Student
{
int *number;
char *name;
double *marks;
};
int main(){
int n;
Student *s;
s = new Student;
cout << "Enter the number of subjects the student learns: ";
cin >> n;
s->number= new int;
s->name=new char[20];
s->marks=new double[n];
cout << "Enter the name of the student: ";
cin >> s->name;
cout << "Enter the number in class of " << s->name << ": ";
cin >> *(s->number);
for (int i = 0 ; i < n …Run Code Online (Sandbox Code Playgroud)