功能如下
Exercise 4 : Please design a C++ program which allows user to enter the total students in class, student’s name, id and 3 scores, please do the followings:
1.Show Exercise No., Class, Name, and ID
2.Enter the total students, student’s name, id and 3 scores
3.Show all the student’s records
4.Show the distribution of each course
5.Ues new and delete operators to allocate memory dynamincally
Hints : struct Student{ // 定义一个结构资料型态Student
string id;
string name;
int score;
float average;
} ;
Student *rptr=new Student;
rptr.name=“Eric”;
Exercise 4
Class : x子xA Name : xxx ID : D9833045
How many students in class : 2
Name of student 1 : Eric
ID of student 1 : D9833007
Score 1 of student 1 : 89
Score 2 of student 1 : 56
Score 3 of student 1 : 74
Name of student 2 : Mary
ID of student 2 : D9833004
Score 1 of student 2 : 80
Score 2 of student 2 : 66
Score 3 of student 2 : 44
…………
Press any key to print class record
Name ID Score1 Score2 Score3 Average
Eric D9833007 89 56 74 73
Mary D9833004 80 66 44 63
…………
最主要显示这个
Course 1 :
100~90 : 0
89~80 : 0
79~70 : 1
Name: Eric ID:D9833007 Score:73
69~60 : 1
Name: Mary ID:D9833004 Score:63
59~0 : 0 ………….
事实上我已经写好了
但是写的很长觉的自已写的很猪头
不知道有没有比较简短的写法
不知道哪一位大大可以帮我解
Hints : struct Student{ // 定义一个结构资料型态Student
string id;
string name;
int score;
float average;
} ;
Student *rptr=new Student; <--还有这二段我看不太了解
rptr.name=“Eric”; <--不知道哪一位大大可以帮我
说明一下
为什么可这样做
这是我写的程式
//
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i,j,n;
int max=0,min=0;
int total={0};
cout <<"Exercise 4"<<endl;
cout <<"Class : X子XA Name : XXX ID : DXXXXXXXXX " << endl;
cout <<"How many students in class:";
cin >> n;
struct person {char name;// 定义一个结构资料型态Student
..
访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容