
class CStudent { int nNumber[5]; char name[5][20]; int nChinese[5]; int nMath[5]; int nEnglish[5]; int nAveChinese; int nAveMath; int nAveEnglish; int nSumChinese; int nSumMath; int nSumEnglish; public: CStudent(char name1[][20]) { for (int i = 0; i < 5; i++) { nNumber[i] = i + 1; strcpy(name[i], name1[i]); nChinese[i] = rand()%90 + 60; nMath[i] = rand()%90 + 60; nEnglish[i] = rand()%90 + 60; } nAveChinese = 0; nAveMath = 0; nAveEnglish = 0; nSumChinese = 0; nSumMath = 0; nSumEnglish = 0; } void PrintAll(); void PrintAveChinese(); void PrintAveMath(); void PrintAveEnglish(); friend void Print(CStudent student); }; void CStudent::PrintAll() { cout<<"学号\t"<<"姓名\t"<<"语文\t"<<"数学\t"<<"英语"<<endl; for (int i = 0; i < 5; i++) { cout<<nNumber[i]<<"\t"<<name[i]<<"\t"<<nChinese[i]<<"\t"<<nMath[i]<<"\t"<<nEnglish[i]<<endl; } } void Print(CStudent student) { for (int i = 0; i < 5; i++) { cout<<studentnNumber[i]<<"\t"<<studentname[i]<<"\t"; if (studentnChinese[i] >= 140) cout<<"优\t"; else if (studentnChinese[i] < 140 && studentnChinese[i] >= 120) cout<<"良\t"; else if (studentnChinese[i] < 120 && studentnChinese[i] >= 100) cout<<"中\t"; else if (studentnChinese[i] < 100 && studentnChinese[i] >= 90) cout<<"及格\t"; else cout<<"不及格\t"; if (studentnMath[i] >= 140) cout<<"优\t"; else if (studentnMath[i] < 140 && studentnMath[i] >= 120) cout<<"良\t"; else if (studentnMath[i] < 120 && studentnMath[i] >= 100) cout<<"中\t"; else if (studentnMath[i] < 100 && studentnMath[i] >= 90) cout<<"及格\t"; else cout<<"不及格\t"; if (studentnEnglish[i] >= 140) cout<<"优\t"; else if (studentnEnglish[i] < 140 && studentnEnglish[i] >= 120) cout<<"良\t"; else if (studentnEnglish[i] < 120 && studentnEnglish[i] >= 100) cout<<"中\t"; else if (studentnEnglish[i] < 100 && studentnEnglish[i] >= 90) cout<<"及格\t"; else cout<<"不及格\t"; cout<<endl; } } void CStudent::PrintAveChinese() { for (int i = 0; i < 5; i++) nSumChinese += nChinese[i]; nAveChinese = nSumChinese/5; cout<<"语文平均成绩:"<<nAveChinese<<endl; } void CStudent::PrintAveMath() { for (int i = 0; i < 5; i++) nSumMath += nMath[i]; nAveMath = nSumMath/5; cout<<"数学平均成绩:"<<nAveMath<<endl; } void CStudent::PrintAveEnglish() { for (int i = 0; i < 5; i++) nSumEnglish += nEnglish[i]; nAveEnglish = nSumEnglish/5; cout<<"英语平均成绩:"<<nAveEnglish<<endl; } int _tmain(int argc, _TCHAR argv[]) { srand(time(NULL)); char name1[5][20] = {"SZW", "SDL", "LHW", "LH", "LJ"}; CStudent student(name1); //student = new CStudent; studentPrintAll(); studentPrintAveChinese(); studentPrintAveMath(); studentPrintAveEnglish(); Print(student); }
记得采纳啊
1d1-->d2-->d3-->d4(线形关系)
2语句的频度就是该语句执行的次数:
(1)执行了n-1次,即用线性阶表示就是o(n)
(2)执行了n-1次, 即用线性阶表示就是o(n)
(3)执行了n-1次,即用线性阶表示就是o(n)
(4)执行了(n+1)n/2次, 用平方阶表示就是o (nn)
3我是用的快速排序,也有其它的方法
#include <stdioh>
void getMax(int a,int b,int c){
int m;
if (a<b){
m=b;b=a;a=m;
}
if (a<c){
m=c;c=a;a=m;
}
if (b<c){
m=c;c=b;b=m;
}
printf("%d%d%d",a,b,c);
}
void main(){
int a;
int b;
int c;
printf("please input a,b,c");
scanf("%d%d%d",&a,&b,&c);
getMax(a,b,c);
}
4#include <stdioh>
int importw(){
int n;
int i;
int maxint=1000000000;
long max=1;
printf("请输入正整数n:\n");
scanf("%d",&n);
if (n<=0){
n=importw();
}
else if (n>20){
printf("输入的n大于存储长度,请您输入n小于20");
n=importw();
}
else{
if (n==1){
max=2;
}
else{
for (i=1;i<=n;i++){
max=maxi;
}
max=max2;
if (max>maxint||max<0){
printf("您输入的n值过大,请重新输入\n");
n=importw();
}
}
}
return n;
}//得到正确的n值
void accountw(){
int n;
n=importw();
int a[20];
int i;
int j;
if (n==1){
a[0]=2;
printf("值列表为:\n");
printf("%d",a[0]);
}
else {
a[0]=2;
for (i=1;i<n;i++){
int amass;
amass=amassi;
a[i]=amass2;
}
printf("结果列表:\n");
for (j=1;j<n;j++){
printf("%d\n",a[j]);
}
}
}//计算阶乘的值
void main(){
accountw();
}
以上就是关于数据结构课程设计 问题是:给出n个学生的m门成绩,每个学生的信息由学号、姓名以及各科成绩组成全部的内容,包括:数据结构课程设计 问题是:给出n个学生的m门成绩,每个学生的信息由学号、姓名以及各科成绩组成、高分请高人帮忙数据结构的题目、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)