hello!我還是我,不一樣的煙火!今天,我來給大家繼續發佈openjudge上的題目!(不喜勿噴!本人依舊是個菜雞!)
好了,進入正題,大家一起看標題!!!!!!!【滑稽】【滑稽】【滑稽】
廢話不多說!直接上圖片???
哈哈,被騙了吧!
不玩了!真的上代碼!
01
#include<bits/stdc++.h>
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<bits/stdc++.h>
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<n;i++){
cin>>x;
if(x%2==1){
a[j]=x;j++;
}
}
sort(a,a+j);
cout<<a[0];
for(i=1;i<=j-1;i++)
cout<<','<<a[i];
return 0;
}
03
#include<bits/stdc++.h>
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<n; i++)
cin >> stu[i].name >> stu[i].score;
stable_sort(stu, stu+n);
for (int i=0; i<n; i++)
cout << stu[i].name << " " << stu[i].score << endl;
return 0;
}
04
#include<bits/stdc++.h>
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<<stu[i].id<<" "<<stu[i].tot<<endl;
return 0;
}
05
#include<bits/stdc++.h>
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<<' '<<a[i].fs << endl;
return 0;
}
爲什麼我只發五題呢?因爲我不想讓你們一下子知道全部答案呀!!!
皮不皮?皮不皮?皮不皮?皮不皮?
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈!
求關注(不喜勿噴)!