求错
  • 板块灌水区
  • 楼主sbsbyyyyyssssss
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/11/1 13:58
  • 上次更新2023/11/2 10:26:43
查看原帖
求错
1109338
sbsbyyyyyssssss楼主2023/11/1 13:58

为什么只能输入一次

#include<bits/stdc++.h>
using namespace std;
struct xs
{
	int xh;
	int fs;
	bool operator > (const xs &x)const
	{
		return fs>x.fs;
	}
	void operator ^ (xs &x)
	{
		fs=x.fs;
		xh=x.xh;
	}
} xsm[105];
void swap1(xs a,xs b)
{
	xs temp;
	temp^a;
	a^b;
	b^temp;
}
int n,k;
int main()
{
	cin>>n;
	cin>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>xsm[i].xh;
		cin>>xsm[i].fs;
	}
	for(int i=n;i>=1;i--)
	{
		for(int j=1;j<i;j++)
		{
			if(xsm[j]>xsm[j+1])
			{
				swap1(xsm[j],xsm[j+1]);
			}
		}
	}
	cout<<xsm[k].xh<<" "<<xsm[k].fs;
	return 0;
}

2023/11/1 13:58
加载中...