45(2023.12.8)(求积,阶乘,魔法,剪刀石头布)

45(2023.12.8)(求积,阶乘,魔法,剪刀石头布)_第1张图片

#include
using namespace std;
#include
int arr[250001] = {};
int main()
{
	string str1, str2;
	cin >> str1 >> str2;
	int L1 = str1.length();
	int L2 = str2.length();
	int num1, num2;
	int times = 0;
	for (int i = (L1 - 1);i >= 0;i--)
	{
		num1 = (int)str1[i] - 48;
		for (int j = (L2 - 1);j >= 0;j--)
		{
			num2 = (int)str2[j] - 48;
			arr[250000 - L1 + 1 + i-times] += (num1 * num2);
			times++;
		}
		times = 0;
	}
	for (int i = 250000;i >= 0;i--)
	{
		if (arr[i] >= 10)
		{
			arr[i - 1] += (arr[i] / 10);
			arr[i] %= 10;
		}
	}
	
	for (int i = 0;i <= 250000;i++)
	{
		if (arr[i] != 0)
		{
			for (int j = i;j <= 250000;j++)
			{
				cout << arr[j];
			}
			cout << endl;
			return 0;
		}
	}
	cout << '0' << endl;
	system("pause");
	return 0;
}

 45(2023.12.8)(求积,阶乘,魔法,剪刀石头布)_第2张图片

#include
using namespace std;
#include;
int arr[25001] = {};
int main()
{
	int n;
	cin >> n;
	int start = 1;
	arr[25000] = 1;
	for (int i = 1;i <= n;i++)
	{
		for (int j = 25000;j >= 0;j--)
		{
			arr[j] *= i;
		}
		/*for (int q = 0;q <= 25000;q++)
		{
			if (arr[q] != 0)
			{
				for (int j = q;j <= 25000;j++)
				{
					cout << arr[j]<<" ";
					q = 25001;
				}
				cout << endl;
			}
		}*/
		for (int j = 25000;j >= 0;j--)
		{
			if (arr[j] >= 10)
			{
				arr[j - 1] += arr[j] / 10;
				arr[j] %= 10;
			}
		}
		/*for (int q = 0;q <= 25000;q++)
		{
			if (arr[q] != 0)
			{
				for (int j = q;j <= 25000;j++)
				{
					cout << arr[j] << " ";
					q = 25001;
				}
				cout << endl;
			}
		}*/
	}
	
	for (int i = 0;i <= 25000;i++)
	{
		if (arr[i] != 0)
		{
			for (int j = i;j <= 25000;j++)
			{
				cout << arr[j];
			}
			i = 25001;
		}
	}
	system("pause");
	return 0;
}

#include
using namespace std;
#include
#include
struct Array
{
	int arrr[25001];
};
vectorv;
Array a1;
int arr[25001] = {};
void test(int n)
{
	for (int j = 25000;j >= 0;j--)
	{
		arr[j] = 0;
	}
	arr[25000] = 1;
	for (int i = 1;i <= n;i++)
	{
		for (int j = 25000;j >= 0;j--)
		{
			arr[j] *= i;
		}
		/*for (int q = 0;q <= 25000;q++)
		{
			if (arr[q] != 0)
			{
				for (int j = q;j <= 25000;j++)
				{
					cout << arr[j]<<" ";
					q = 25001;
				}
				cout << endl;
			}
		}*/
		for (int j = 25000;j >= 0;j--)
		{
			if (arr[j] >= 10)
			{
				arr[j - 1] += arr[j] / 10;
				arr[j] %= 10;
			}
		}
		/*for (int q = 0;q <= 25000;q++)
		{
			if (arr[q] != 0)
			{
				for (int j = q;j <= 25000;j++)
				{
					cout << arr[j] << " ";
					q = 25001;
				}
				cout << endl;
			}
		}*/
		
	}
	for (int j = 25000;j >= 0;j--)
	{
		a1.arrr[j] = arr[j];
	}
	v.push_back(a1);

	/*for (int i = 0;i <= 25000;i++)
	{
		if (arr[i] != 0)
		{
			for (int j = i;j <= 25000;j++)
			{
				cout << arr[j];
			}
			i = 25001;
		}
	}*/
}
int main()
{
	int n;
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		test(i);
	}
	int result[25001] = {};
	/*for (vector::iterator it = v.begin();it != v.end();it++)
	{
		for (int i = 0;i <= 25000;i++)
		{
			if ((*it).arrr[i] != 0)
			{
				for (int j = i;j <= 25000;j++)
				{
					cout << (*it).arrr[j];
				}
				i = 25001;
				cout << endl;
			}
		}

	}*/
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		for (int i = 0;i <= 25000;i++)
		{
			result[i] += (*it).arrr[i];
		}
	}


	for (int j = 25000;j >= 0;j--)
	{
		if (result[j] >= 10)
		{
			result[j - 1] += result[j] / 10;
			result[j] %= 10;
		}
	}
	for (int i = 0;i <= 25000;i++)
	{
		if (result[i] != 0)
		{
			for (int j = i;j <= 25000;j++)
			{
				cout << result[j];
			}
			i = 25001;
		}
	}
		system("pause");
		return 0;
	
}

45(2023.12.8)(求积,阶乘,魔法,剪刀石头布)_第3张图片

#include
using namespace std;
#include
int arr[500][500] = {};
struct Zhilin
{
	int m_X;
	int m_Y;
	int m_R;
	int m_Z;
};
int main()
{
	int n, m;
	cin >> n >> m;
	int start = 1;
	Zhilin zhi;
	vectorv;
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < n;j++)
		{
			arr[i][j] = start;
			start++;
		}
	}
	int x, y, r, z;
	for (int i = 0;i < m;i++)
	{
		cin >> x >> y >> r >> z;
		zhi.m_R = r;
		zhi.m_X = x;
		zhi.m_Y = y;
		zhi.m_Z = z;
		v.push_back(zhi);
	}
	vectorv1;
	int r1;
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		r1 = (*it).m_R;
		for (int i = (*it).m_X - r1 - 1;i <= r1 + (*it).m_X - 1;i++)
		{
			for (int j = (*it).m_Y - r1 - 1;j <= (*it).m_Y + r1 - 1;j++)
			{
				v1.push_back(arr[i][j]);
			}
		}
		if ((*it).m_Z == 0)
		{
			vector::iterator pos = v1.begin();
			for (int i = (*it).m_Y + r1 - 1;i >= (*it).m_Y - r1 - 1;i--)
			{
				for (int j = (*it).m_X - r1 - 1;j <= (*it).m_X + r1 - 1;j++)
				{
					arr[j][i] = *pos;
					if (!(i == (*it).m_Y - r1 - 1 && j == (*it).m_X + r1 - 1))
					pos++;
				}
			}

			v1.clear();
		}
		else if ((*it).m_Z == 1)
		{
			vector::iterator pos = v1.begin();
			for (int i = (*it).m_Y - r1 - 1;i <= (*it).m_Y + r1 - 1;i++)
			{
				for (int j = (*it).m_X + r1 - 1;j >= (*it).m_X - r1 - 1;j--)
				{
					arr[j][i] = *pos;
					if (!(i == ((*it).m_Y + r1 - 1) && j == (*it).m_X - r1 - 1))
					pos++;
				}
			}

			v1.clear();
		}
	}
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < n;j++)
		{
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}


	system("pause");
	return 0;
}

 45(2023.12.8)(求积,阶乘,魔法,剪刀石头布)_第4张图片

 45(2023.12.8)(求积,阶乘,魔法,剪刀石头布)_第5张图片

#include
using namespace std;
int main()
{
	int times, xa, xb;
	int logo;
	int a = 0;
	int b = 0;
	int score1 = 0;
	int score2 = 0;
	cin >> times;
	cin>> xa >> xb;
	int arra[201] = {};
	int arrb[201] = {};
	for (int i = 0;i < xa;i++)
	{
		cin >> logo;
		arra[i] = logo;
	}
	for (int i = 0;i < xb;i++)
	{
		cin >> logo;
		arrb[i] = logo;
	}

	/*for (int i = 0;i < xa;i++)
	{
		cout << arra[i] << " ";
	}
	cout << endl;
	for (int i = 0;i < xb;i++)
	{
		cout << arrb[i] << " ";
	}
	cout << endl;*/

	for (int i = 0;i < times;i++)
	{
		if (a == xa)a = 0;
		if (b == xb)b = 0;
		if (arra[a] == 0 && arrb[b] == 1)score2++;
		if (arra[a] == 0 && arrb[b] == 2)score1++;
		if (arra[a] == 0 && arrb[b] == 3)score1++;
		if (arra[a] == 0 && arrb[b] == 4)score2++;
		if (arra[a] == 1 && arrb[b] == 2)score2++;
		if (arra[a] == 1 && arrb[b] == 3)score1++;
		if (arra[a] == 1 && arrb[b] == 4)score2++;
		if (arra[a] == 2 && arrb[b] == 3)score2++;
		if (arra[a] == 2 && arrb[b] == 4)score1++;
		if (arra[a] == 3 && arrb[b] == 4)score1++;

		if (arrb[b] == 0 && arra[a] == 1)score1++;
		if (arrb[b] == 0 && arra[a] == 2)score2++;
		if (arrb[b] == 0 && arra[a] == 3)score2++;
		if (arrb[b] == 0 && arra[a] == 4)score1++;
		if (arrb[b] == 1 && arra[a] == 2)score1++;
		if (arrb[b] == 1 && arra[a] == 3)score2++;
		if (arrb[b] == 1 && arra[a] == 4)score1++;
		if (arrb[b] == 2 && arra[a] == 3)score1++;
		if (arrb[b] == 2 && arra[a] == 4)score2++;
		if (arrb[b] == 3 && arra[a] == 4)score2++;
		a++;
		b++;
	}
	cout << score1 << " " << score2;
	system("pause");
	return 0;
}

 

 

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