功能如下
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 可以看到全部內容