openjudge 1.10编程基础之简单排序

hello!我还是我,不一样的烟火!今天,我来给大家继续发布openjudge上的题目!(不喜勿喷!本人依旧是个菜鸡!)

好了,进入正题,大家一起看标题!!!!!!!【滑稽】【滑稽】【滑稽】

废话不多说!直接上图片???openjudge 1.10编程基础之简单排序_第1张图片

哈哈,被骗了吧!

不玩了!真的上代码!

01

#include
using namespace std;
struct c{
	int xh;
	float cj;
}a[1000];
bool compare(const c &a,const c &b){
	return a.cj>b.cj;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d %f",&a[i].xh,&a[i].cj);
	sort(a+1,a+n+1,compare);
	printf("%d %g",a[k].xh,a[k].cj);
    return 0;
} 

02

#include
using namespace std; 
int cmp(int a, int b){ 
	return a > b; 
}
int main(){
	int n,x;
	cin>>n;
	int a[n],i,j=0;
	for(i=0;i>x;
		if(x%2==1){ 
			a[j]=x;j++;
		}
	}
	sort(a,a+j);
	cout<

03

#include
using namespace std;
struct student{
    string name;
    int score;
} stu[21];
bool operator<(student a, student b){
    if (a.score != b.score)
        return a.score > b.score;
    if (a.name.compare(b.name) <= 0)
        return true;
    else
        return false;
}
int main(){
    int n;
    cin >> n;
    for (int i=0; i> stu[i].name >> stu[i].score;
    stable_sort(stu, stu+n);
    for (int i=0; i

04

#include
using namespace std;
struct score{
	int id, tot,chi,math, eng;
}stu[305];
bool cmp(score a, score b){
	if (a.tot!=b.tot) 
		return a.tot > b.tot;
	else if (a.chi!=b.chi) 
		return a.chi>b.chi;
	else
		return a.id < b.id;
}
int main(){
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		stu[i].id = i;
		cin >> stu[i].chi>>stu[i].math>>stu[i].eng;
		stu[i].tot=stu[i].chi+stu[i].math+stu[i].eng;
	}
	sort(stu+1,stu+1+n,cmp);
	for (int i=1;i<=5;i++)
		cout<

05

#include
using namespace std;
struct score {
	int id,fs;
}a[5005];
bool cmp(score x, score y){
	if (x.fs != y.fs)
	return x.fs > y.fs;
	else
	return x.id < y.id;
}
int main(){
	int n, num;
	cin >> n >> num;
	num *=1.5; 
	for (int i= 1; i<=n; i++)
		cin >> a[i].id >> a[i].fs;
	sort(a+1, a+n+1, cmp);
	int j = num;
	do{
		j++;
	} while (a[j].fs == a[num].fs && j<=n);
	cout << a[j-1].fs <<" "<< j-1 << endl;
	for (int i=1; i<=j-1; i++)
		cout << a[i].id<<' '<

为什么我只发五题呢?因为我不想让你们一下子知道全部答案呀!!!

皮不皮?皮不皮?皮不皮?皮不皮?

 哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈!

求关注(不喜勿喷)!

你可能感兴趣的:(openjudge)