(2).txt

来自「最后声明」· 文本 代码 · 共 34 行

TXT
34
字号
#include<iostream>
using namespace std;
class Student{
	char name[10];
	float score;
public:
	Student(char n[],char s)
	{strcpy(name,n);
	score=s;
	}
	char*getname(){return name;}
	friend float compare(Student&S1,Student&S2)
	{
		if(S1.s>S2.s)
			return 1;
		else if(S1.s==S2.s)
			return 0;
		else return -1;
	}
};
void main()
{Student st[]={Student("Lily",90),Student("Lucy",80),Student("Tom",70),Student("Sam",60)};
int i,min=0,max=0;
for(i=0;i<4;i++)
{if(compare(st[max],st[i])==-1)
	max=i;
else if(comepare(st[min],st[i]==1)
		min=i;
}
cout<<"The result is:"<<endl;
cout<<"The highest score is:"<<st[max].getname()<<endl;
cout<<"The lowest score is:"<<st[min].getname()<<endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?