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

51(2023.12.20)(蓝桥杯练习)ji2_第1张图片

#include
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;
}

51(2023.12.20)(蓝桥杯练习)ji2_第2张图片 

#include
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;
}

51(2023.12.20)(蓝桥杯练习)ji2_第3张图片 

 //答辩代码

#include
using namespace std;
#include
#include
#include
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;
	listv1;
	for (int i = 1;i <= n;i++)
	{
		v1.push_back(i);
	}
	vectorv2;
	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::iterator pos;
	for (vector::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::iterator it = v1.begin();it != v1.end();it++)
	{
		cout << *it << " ";
	}
	system("pause");
	return 0;
}
#include
using namespace std;
#include
int arr[100000] = {};
#include
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;
	vectorv;
	for (int i = 0;i < m;i++)
	{
		cin >> num1 >> num2;
		p.m_Num1 = num1;
		p.m_Num2 = num2;
		v.push_back(p);
	}
	sets;
	int flag;
	for (vector::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::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::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;
}

 

 

你可能感兴趣的:(算法,c++,数据结构)