?? hw5-1.cpp
字號:
#include <iostream.h>
#include <string.h>
class Student {
char name[10];
float math, comp, eng, avg;
static float allscore;
static int num;
public:
Student(char *sn, float m, float c, float e) {
strcpy(name, sn);
math = m;
comp = c;
eng = e;
avg = (m + c + e) / 3;
allscore += avg;
num ++;
}
void Show() {
cout << "姓名:" << name << " 平均成績:" << avg << endl;
}
static void AllAverage() {
cout << "\n總平均值是:" << allscore / num << endl << endl;
}
};
float Student::allscore = 0;
int Student::num = 0;
void main() {
Student stu[5] = { Student("黎 明", 78, 89, 82),
Student("張學友", 85, 97, 87),
Student("劉德華", 67, 92, 83),
Student("郭富成", 64, 78, 75),
Student("張國榮", 84, 92, 90) };
for(int i = 0; i < 5; i ++)
stu[i].Show();
Student::AllAverage();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -