44(2023.12.7)乒乓球,扫雷,玩具人,加法

44(2023.12.7)乒乓球,扫雷,玩具人,加法_第1张图片

#include
using namespace std;
#include
struct Score1
{
	int z;
	int y;
};
struct Score2
{
	int z;
	int y;
};
int main()
{
	char ch='1';
	int z1=0, z2=0, y1=0, y2=0;
	Score1 s1;
	Score2 s2;
	vectorv1;
	vectorv2;
	while (ch != 'E')
	{
		cin >> ch;
		if (ch == 'W')
		{
			z1++;
			z2++;
		}
		else if (ch == 'L')
		{
			y1++;
			y2++;
		}
		if ((y1 >= 11 || z1 >= 11) && abs(y1 - z1) >= 2)
		{
			s1.z = z1;
			s1.y = y1;
			v1.push_back(s1);
			z1 = 0;
			y1 = 0;
		}
		if ((y2 >= 21 || z2 >= 21) && abs(y2 - z2) >= 2)
		{
			s2.z = z2;
			s2.y = y2;
			v2.push_back(s2);
			z2 = 0;
			y2 = 0;
		}
	}

		s1.z = z1;
		s1.y = y1;
		v1.push_back(s1);
	if (z2 != 0 || y2 != 0)
	{
		s2.z = z2;
		s2.y = y2;
		v2.push_back(s2);
	}
	for (vector::iterator it = v1.begin();it != v1.end();it++)
	{
		cout << (*it).z << ':' << (*it).y << endl;
	}
	if (v1.empty())cout << "0:0" << endl;
	cout << endl;
	for (vector::iterator it = v2.begin();it != v2.end();it++)
	{
		cout << (*it).z << ':' << (*it).y << endl;
	}
	if (v2.empty())cout << "0:0" << endl;
	system("pause");
	return 0;
}

 44(2023.12.7)乒乓球,扫雷,玩具人,加法_第2张图片

#include
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	char arr1[101][101] = {};
	int arr2[101][101] = {};
	char ch;
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			cin >> ch;
			arr1[i][j] = ch;
		}
	}
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			if (arr1[i][j] == '*')
			{
				if (arr2[i - 1][j]<=9)arr2[i - 1][j] += 1;
				if (arr2[i + 1][j] <= 9)arr2[i + 1][j] += 1;
				if (arr2[i][j - 1] <= 9)arr2[i][j - 1] += 1;
				if (arr2[i][j + 1] <= 9)arr2[i][j + 1] += 1;
				if (arr2[i - 1][j - 1] <= 9)arr2[i - 1][j - 1] += 1;
				if (arr2[i + 1][j + 1] <= 9)arr2[i + 1][j + 1] += 1;
				if (arr2[i - 1][j + 1] <= 9)arr2[i - 1][j + 1] += 1;
				if (arr2[i + 1][j - 1] <= 9)arr2[i + 1][j - 1] += 1;
			}
		}
	}
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			if (arr1[i][j] == '*')
			{
				cout << arr1[i][j];
			}
			else
			{
				cout << arr2[i][j];
			}
		}
		cout << endl;
	}
	system("pause");
	return 0;
}

 44(2023.12.7)乒乓球,扫雷,玩具人,加法_第3张图片

44(2023.12.7)乒乓球,扫雷,玩具人,加法_第4张图片

#include
using namespace std;
#include
#include
struct Person
{
	char m_Neiwai;
	string m_Carrer;
};
int main()
{
	int n, m;
	cin >> n >> m;
	char neiwai;
	string carrer;
	vectorv;
	Person p;
	for (int i = 0;i < n;i++)
	{
		cin >> neiwai;
		cin >> carrer;
		p.m_Neiwai = neiwai;
		p.m_Carrer = carrer;
		v.push_back(p);
	}
	char ch1;
	int times;
	string result;
	vector::iterator pos = v.begin();
	vector::iterator pos1 = v.end();
	pos1--;
	for (int i = 0;i < m;i++)
	{
		cin >> ch1;
		cin >> times;
		if (ch1 == '0')
		{
			if ((*pos).m_Neiwai == '0')
			{
				for (int j = 0;j < times;j++)
				{
					if (pos == v.begin())
					{
						pos = pos1;
					}
					else
					{
						pos--;
					}
				}
			}
			else if ((*pos).m_Neiwai == '1')
			{
				for (int j = 0;j < times;j++)
				{
					if (pos == pos1)
					{
						pos = v.begin();
					}
					else
					{
						pos++;
					}
				}
			}
		}
		else if(ch1=='1')
		{
			if ((*pos).m_Neiwai == '0')
			{
				for (int j = 0;j < times;j++)
				{
					if (pos == pos1)
					{
						pos = v.begin();
					}
					else
					{
						pos++;
					}
				}
			}
			else if ((*pos).m_Neiwai == '1')
			{
				for (int j = 0;j < times;j++)
				{
					if (pos == v.begin())
					{
						pos = pos1;
					}
					else
					{
						pos--;
					}
				}
			}
		}
	}
	cout<<(*pos).m_Carrer<
#include
using namespace std;
#include
#include
struct Person
{
	char m_Neiwai;
	string m_Carrer;
};
int main()
{
	int n, m;
	cin >> n >> m;
	char neiwai;
	string carrer;
	vectorv;
	Person p;
	for (int i = 0;i < n;i++)
	{
		cin >> neiwai;
		cin >> carrer;
		p.m_Neiwai = neiwai;
		p.m_Carrer = carrer;
		v.push_back(p);
	}
	char ch1;
	int times;
	string result;
	long long ababab;
	vector::iterator pos = v.begin();
	vector::iterator pos1 = v.end();
	pos1--;
	long long abab = 0;
	int resultt;
	for (int i = 0;i < m;i++)
	{
		cin >> ch1;
		cin >> times;
		if (ch1 == '0')
		{
			if ((*pos).m_Neiwai == '0')
			{
				abab = times;
				int resultt = (times % v.size());
				for (int j = 0;j < resultt;j++)
				{
					if (pos == v.begin())
					{
						pos = pos1;
					}
					else
					{
						pos--;
					}
				}
				
			}
			else if ((*pos).m_Neiwai == '1')
			{
				abab = times;
				int resultt = (times % v.size());
				for (int j = 0;j < resultt;j++)
				{
					if (pos == pos1)
					{
						pos = v.begin();
					}
					else
					{
						pos++;
					}
				}
			}
		}
		else if(ch1=='1')
		{
			if ((*pos).m_Neiwai == '0')
			{
				abab = times;
				int resultt = (times % v.size());
				for (int j = 0;j < resultt;j++)
				{
					if (pos == pos1)
					{
						pos = v.begin();
					}
					else
					{
						pos++;
					}
				}
			}
			else if ((*pos).m_Neiwai == '1')
			{
				abab = times;
				int resultt = (times % v.size());
				for (int j = 0;j < resultt;j++)
				{
					if (pos == v.begin())
					{
						pos = pos1;
					}
					else
					{
						pos--;
					}
				}
			}
		}
	}
	
	cout << (*pos).m_Carrer << endl;
	return 0;
}

 44(2023.12.7)乒乓球,扫雷,玩具人,加法_第5张图片

 44(2023.12.7)乒乓球,扫雷,玩具人,加法_第6张图片

#include
using namespace std;
#include
int main()
{
	int arr[502] = {};
	string str1, str2;
	cin >> str1 >> str2;
	int l1 = str1.length();
	int l2 = str2.length();
	for (int i = l1-1;i >=0;i--)
	{
		arr[501 + i - l1+1] += ((int)str1[i] - 48);
		if (arr[501 + i - l1+1] >= 10)
		{
			arr[501 + i - l1+1] -= 10;
			arr[501 + i - l1  ] += 1;
		}
	}
	for (int i = l2 - 1;i >= 0;i--)
	{
		arr[(501 + i - l2+1 )] += ((int)str2[i] - 48);
		if (arr[(501 + i - l2+1 )] >= 10)
		{
			arr[(501 + i - l2+1 )] -= 10;
			arr[(501 + i - l2  )] += 1;
		}
	}
	for (int i = 0;i < 502;i++)
	{
		if (arr[i] != 0)
		{
			for (int j = i;j < 502;j++)
			{
				cout << arr[j];
			}
			return 0;
		}
		
	}
	cout << 0 << endl;
	system("pause");
	return 0;
}

 

你可能感兴趣的:(算法)