51(2023.12.20)(蓝桥杯练习)ji2

发布时间:2023年12月21日

#include<iostream>
using namespace std;
int main()
{
	int arr[5] = {};
	for (int i = 0;i < 32;i++)
	{
		for (int j = 0;j < 5;j++)
		{
			cout << arr[j];
		}
		cout << endl;
		arr[4]++;
		for (int j = 4;j >= 1;j--)
		{
			if (arr[j] == 2)
			{
				arr[j] = 0;
				arr[j - 1]++;
			}
		}
	}
	system("pause");
	return 0;
}

?

#include<iostream>
using namespace std;
int main()
{
	int year;
	cin >> year;
	if (year % 100 == 0)
	{
		if (year % 400 == 0)
		{
			cout << "yes";
		}
		else
		{
			cout << "no";
		}

	}
	else
	{
		if (year % 4 == 0)
		{
			cout << "yes";
		}
		else
		{
			cout << "no";
		}
	}
	system("pause");
	return 0;
}

?

?//答辩代码

#include<iostream>
using namespace std;
#include<list>
#include<algorithm>
#include<vector>
struct paixv
{
	int m_Num1;
	int m_Num2;
};
bool mycompare(int v1, int v2)
{
	return v1 > v2;
}
int main()
{
	int n, m;
	cin >> n >> m;
	list<int>v1;
	for (int i = 1;i <= n;i++)
	{
		v1.push_back(i);
	}
	vector<paixv>v2;
	paixv p;
	int num1, num2;
	for (int i = 0;i < m;i++)
	{
		cin >> num1 >> num2;
		p.m_Num1 = num1;
		p.m_Num2 = num2;
		v2.push_back(p);
	}
	list<int>::iterator pos;
	for (vector<paixv>::iterator it = v2.begin();it != v2.end();it++)
	{
		pos = v1.begin();
		if ((*it).m_Num1 == 1)
		{
			for (int i = 0;i < (*it).m_Num2;i++)
			{
				pos++;
			}
			sort(v1.begin(), pos);
		}
		else
		{
			for (int i = 0;i < (*it).m_Num2;i++)
			{
				pos++;
			}
			sort(v1.begin(), pos);
		}
	}
	for (list<int>::iterator it = v1.begin();it != v1.end();it++)
	{
		cout << *it << " ";
	}
	system("pause");
	return 0;
}
#include<iostream>
using namespace std;
#include<set>
int arr[100000] = {};
#include<vector>
struct paixv
{
	int m_Num1;
	int m_Num2;

};
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < n;i++)
	{
		arr[i] = i + 1;
	}
	paixv p;
	int num1, num2;
	vector<paixv>v;
	for (int i = 0;i < m;i++)
	{
		cin >> num1 >> num2;
		p.m_Num1 = num1;
		p.m_Num2 = num2;
		v.push_back(p);
	}
	set<int>s;
	int flag;
	for (vector<paixv>::iterator it = v.begin();it != v.end();it++)
	{
		
		if ((*it).m_Num1 == 0)
		{
			s.clear();
			for (int i = 0;i < (*it).m_Num2;i++)
			{
				s.insert(arr[i]);
			}
			flag = (*it).m_Num2;
			for (set<int>::iterator itt = s.begin();itt != s.end();itt++)
			{
				flag--;
				arr[flag] = *itt;
			}
			/*for (int j = 0;j < n;j++)
			{
				cout << arr[j] << " ";
			}
			cout << endl;*/
		}
		else if((*it).m_Num1==1)
		{
			s.clear();
			for (int i = (*it).m_Num2-1;i < n;i++)
			{
				s.insert(arr[i]);
			}
			flag = (*it).m_Num2 - 1;
			for (set<int>::iterator itt = s.begin();itt != s.end();itt++)
			{
				arr[flag] = *itt;
				flag++;
			}
			/*for (int j = 0;j < n;j++)
			{
				cout << arr[j] << " ";
			}
			cout << endl;*/
		}
	}
	for (int i = 0;i < n;i++)
	{
		cout << arr[i] << " ";
	}
	system("pause");
	return 0;
}

?

?

文章来源:https://blog.csdn.net/weixin_72770922/article/details/135117657
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。