求助,2,6,8,9过不了
查看原帖
求助,2,6,8,9过不了
536794
zzzzk丶楼主2021/9/8 19:30
#include <iostream>
#include <cstring>
using namespace std;
struct people
{
	string name="ceshi";
	string gongzuo="ceshi";
	long long int banggong=0;
	int dengji=0;
}chengyuan[151];
int main()
{
	int n;
	cin >> n;
	int count=0;
	for (int i = 0; i < n; i++)
	{
		cin >> chengyuan[i].name;
		cin >> chengyuan[i].gongzuo;
		cin >> chengyuan[i].banggong;
		cin >> chengyuan[i].dengji;
	}
	for (int i = 0;; i++)
	{
		if (!(chengyuan[i].gongzuo == "BangZhu" || chengyuan[i].gongzuo == "FuBangZhu"))
			break;
		cout << chengyuan[i].name <<" ";
		cout << chengyuan[i].gongzuo  << " ";
		cout << chengyuan[i].dengji << endl;
		count++;
	}
	if (n ==count)
		return 0;
	for (int i = 0; i < n-count; i++)
	{
		for (int j = count; j < n - i - 1; j++)
		{
			if (chengyuan[j].banggong < chengyuan[j + 1].banggong)
			{
				chengyuan[150] = chengyuan[j];
				chengyuan[j] = chengyuan[j + 1];
				chengyuan[j + 1] = chengyuan[150];
			}
		}
	}
	for (int i = 0; i < 2; i++)
	{
		for (int j = count; j < count + 2 - 1 - i; j++)
		{ 
			if (chengyuan[j].dengji < chengyuan[j + 1].dengji)
			{
				chengyuan[150] = chengyuan[j];
				chengyuan[j] = chengyuan[j + 1];
				chengyuan[j + 1] = chengyuan[150];
			}
		}
	}
	for (int i = count; i < count + 2; i++)
	{
		if (i >= n)
			break;
		cout << chengyuan[i].name << " HuFa " << chengyuan[i].dengji << endl;;
	}
	for (int i = 0; i <  4; i++)
	{
		for (int j = count+2; j < count + 6 - 1 - i; j++)
		{
			if (chengyuan[j].dengji < chengyuan[j + 1].dengji)
			{
				chengyuan[150] = chengyuan[j];
				chengyuan[j] = chengyuan[j + 1];
				chengyuan[j + 1] = chengyuan[150];
			}
		}
	}
	for (int i = count+2; i < count + 6; i++)
	{
		if (i >=n)
			break;
		cout << chengyuan[i].name << " ZhangLao " << chengyuan[i].dengji << endl;;
	}
	for (int i = 0; i < 7; i++)
	{
		for (int j = count + 6; j < count + 13 - 1 - i; j++)
		{
			if (chengyuan[j].dengji < chengyuan[j + 1].dengji)
			{
				chengyuan[150] = chengyuan[j];
				chengyuan[j] = chengyuan[j + 1];
				chengyuan[j + 1] = chengyuan[150];
			}
		}
	}
	for (int i = count + 6; i < count + 13; i++)
	{
		if (i >= n)
			break;
		cout << chengyuan[i].name << " TangZhu " << chengyuan[i].dengji << endl;;
	}
	for (int i = 0; i < 25; i++)
	{
		for (int j = count + 13; j < count + 38 - 1 - i; j++)
		{
			if (chengyuan[j].dengji < chengyuan[j + 1].dengji)
			{
				chengyuan[150] = chengyuan[j];
				chengyuan[j] = chengyuan[j + 1];
				chengyuan[j + 1] = chengyuan[150];
			}
		}
	}
	for (int i = count + 13; i < count + 38; i++)
	{
		if (i >= n)
			break;
		cout << chengyuan[i].name << " JingYing " << chengyuan[i].dengji << endl;;
	}
	for (int i = 0; i < n-38; i++)
	{
		for (int j = count + 38; j < n - 1 - i; j++)
		{
			if (chengyuan[j].dengji < chengyuan[j + 1].dengji)
			{
				chengyuan[150] = chengyuan[j];
				chengyuan[j] = chengyuan[j + 1];
				chengyuan[j + 1] = chengyuan[150];
			}
		}
	}
	for (int i = count + 38; i < n; i++)
	{
		if (i >= n)
			break;
		cout << chengyuan[i].name << " BangZhong " << chengyuan[i].dengji << endl;;
	}
	return 0;
}
2021/9/8 19:30
加载中...