qwq,大家,我回来了!断更两个月了!qwq!
今天我来水文章了!
so easy
首先是整数奇偶排序
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[10];
for(int i=0;i<10;i++)
{
cin>>a[i];
}
for(int i=0;i<10-1;i++)
{
for(int j=i+1;j<10;j++)
{
if((a[i]%2!=0&&a[j]%2!=0)&&a[i]<a[j])
{
swap(a[i],a[j]);
}
else if(a[i]%2==0&&a[j]%2!=0)
{
swap(a[i],a[j]);
}
else if((a[i]%2==0&&a[j]%2==0)&&a[i]>a[j])
{
swap(a[i],a[j]);
}
}
}
for(int i=0;i<10;i++)
{
cout<<a[i]<<' ';
}
cout<<endl;
return 0;
}
再是1938:【07NOIP普及组】奖学金
#include<bits/stdc++.h>
using namespace std;
struct student
{
int yu;
int shu;
int ying;
int xuehao;
}stu[300];
int main()
{
int n;
cin>>n;
int a[n+1];
for(int i=1;i<=n;i++)
{
cin>>stu[i].yu>>stu[i].shu>>stu[i].ying;
a[i]=stu[i].yu+stu[i].shu+stu[i].ying;
stu[i].xuehao=i;
}
for(int i=1;i<n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(a[i]==a[j]&&stu[j].yu>stu[i].yu)
{
swap(stu[j],stu[i]);
swap(a[i],a[j]);
}
else if(a[i]<a[j])
{
swap(stu[i],stu[j]);
swap(a[i],a[j]);
}
else if(a[i]==a[j]&&stu[i].yu==stu[j].yu&&stu[j].xuehao<stu[i].xuehao)
{
swap(stu[i],stu[j]);
swap(a[i],a[j]);
}
}
}
for(int i=1;i<=5;i++)
{
cout<<stu[i].xuehao<<" "<<a[i]<<endl;
}
return 0;
}
好了今天的水文章就到这了!(逃
今天屁孩君就分享到这里了!古德拜!
记得三连欧!