35(2023.11.26):打题

幻方

35(2023.11.26):打题_第1张图片

#include
using namespace std;
int main()
{
	int N, h, l;
	cin >> N;
	int arr[40][40] = {};
	int zhong = N  / 2;
	h = 0;
	l = N / 2;
	arr[0][zhong] = 1;
	for (int i = 2;i <= N*N;i++)
	{
		if (h == 0 && l != N - 1)
		{
			h = N - 1;
			l += 1;
			arr[h][l]=i;
		}
		else if (l == N - 1 && h != 0)
		{
			l = 0;
			h--;
			arr[h][l] = i;
		}
		else if (h == 0 && l == N - 1)
		{
			h++;
			arr[h][l] = i;
		}
		else if (h != 0 && l != N - 1)
		{
			if (arr[h - 1][l + 1] == 0)
			{
				h = h - 1;
				l = l + 1;
				arr[h][l] = i;
			}
			else
			{
				h++;
				arr[h][l] = i;
			}
		}
	}
	for (int i = 0;i < N;i++)
	{
		for (int j = 0;j < N;j++)
		{
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}
	system("pause");
	return 0;
}

35(2023.11.26):打题_第2张图片

#include
#include
int main()
{
	double x1,y1,x2,y2;
	char ch1,ch2;
	scanf("%lf%c%lf%lf%c%lf",&x1,&ch1,&y1,&x2,&ch2,&y2);
	double x=x2-x1;
	double y=y2-y1;
	double result=sqrt(x*x+y*y);
	printf("%.6lf",result);
	return 0;
 } 

35(2023.11.26):打题_第3张图片

#include
#include
int main()
{
	double x1,y1,x2,y2,x3,y3;
	char ch1,ch2,ch3;
	scanf("%lf%c%lf%lf%c%lf%lf%c%lf",&x1,&ch1,&y1,&x2,&ch2,&y2,&x3,&ch3,&y3);
	double a=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
	double b=sqrt((y2-y3)*(y2-y3)+(x2-x3)*(x2-x3));
	double c=sqrt((y1-y3)*(y1-y3)+(x1-x3)*(x1-x3));
	double s=(a+b+c)/2;
	double result=sqrt(s*(s-a)*(s-b)*(s-c));
	printf("%.6lf",result);
	return 0;
 } 

 35(2023.11.26):打题_第4张图片

#include
#include
int main()
{
	double r;
	scanf("%lf",&r);
	double pi=3.141592653589793;
	double result=(1.0*4/3)*pi*r*r*r;
	printf("%.6lf",result);
	return 0;
 } 

 35(2023.11.26):打题_第5张图片

#include
#include
int main()
{
	double r;
	scanf("%lf",&r);
	double pi=3.141592653589793;
	double result1=2*pi*r;
	double result2=pi*r*r;
	printf("%.6lf",result1);
	printf("%.6lf",result2);
	return 0;
 } 

 35(2023.11.26):打题_第6张图片

#include
using namespace std;
int main()
{
	int n;
	cin >> n;
	char ch[100] = {};
	char chh;
	for (int i = 0;i < n;i++)
	{
		cin >> chh;
		ch[i] = chh;
	}
	for (int i = 0;i < n-1;i++)
	{
		if (ch[i] == '0')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '1')
		{
			cout << "..X.";
		}
		else if (ch[i] == '2')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '3')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '4')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '5')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '6')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '7')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '8')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '9')
		{
			cout << "XXX.";
		}
	}
	if (ch[n - 1] == '0')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '1')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '2')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '3')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '4')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '5')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '6')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '7')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '8')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n-1] == '9')
	{
		cout << "XXX" << endl;
	}
	//第二行
	for (int i = 0;i < n - 1;i++)
	{
		if (ch[i] == '0')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '1')
		{
			cout << "..X.";
		}
		else if (ch[i] == '2')
		{
			cout << "..X.";
		}
		else if (ch[i] == '3')
		{
			cout << "..X.";
		}
		else if (ch[i] == '4')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '5')
		{
			cout << "X...";
		}
		else if (ch[i] == '6')
		{
			cout << "X...";
		}
		else if (ch[i] == '7')
		{
			cout << "..X.";
		}
		else if (ch[i] == '8')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '9')
		{
			cout << "X.X.";
		}
	}
	if (ch[n - 1] == '0')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '1')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '2')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '3')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '4')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '5')
	{
		cout << "X.." << endl;
	}
	else if (ch[n - 1] == '6')
	{
		cout << "X.." << endl;
	}
	else if (ch[n - 1] == '7')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '8')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '9')
	{
		cout << "X.X" << endl;
	}
	//第三行
	for (int i = 0;i < n - 1;i++)
	{
		if (ch[i] == '0')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '1')
		{
			cout << "..X.";
		}
		else if (ch[i] == '2')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '3')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '4')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '5')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '6')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '7')
		{
			cout << "..X.";
		}
		else if (ch[i] == '8')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '9')
		{
			cout << "XXX.";
		}
	}
	if (ch[n - 1] == '0')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '1')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '2')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '3')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '4')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '5')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '6')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '7')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '8')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '9')
	{
		cout << "XXX" << endl;
	}
	//第四行
	for (int i = 0;i < n - 1;i++)
	{
		if (ch[i] == '0')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '1')
		{
			cout << "..X.";
		}
		else if (ch[i] == '2')
		{
			cout << "X...";
		}
		else if (ch[i] == '3')
		{
			cout << "..X.";
		}
		else if (ch[i] == '4')
		{
			cout << "..X.";
		}
		else if (ch[i] == '5')
		{
			cout << "..X.";
		}
		else if (ch[i] == '6')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '7')
		{
			cout << "..X.";
		}
		else if (ch[i] == '8')
		{
			cout << "X.X.";
		}
		else if (ch[i] == '9')
		{
			cout << "..X.";
		}
	}
	if (ch[n - 1] == '0')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '1')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '2')
	{
		cout << "X.." << endl;
	}
	else if (ch[n - 1] == '3')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '4')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '5')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '6')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '7')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '8')
	{
		cout << "X.X" << endl;
	}
	else if (ch[n - 1] == '9')
	{
		cout << "..X" << endl;
	}
	//第五行
	for (int i = 0;i < n - 1;i++)
	{
		if (ch[i] == '0')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '1')
		{
			cout << "..X.";
		}
		else if (ch[i] == '2')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '3')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '4')
		{
			cout << "..X.";
		}
		else if (ch[i] == '5')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '6')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '7')
		{
			cout << "..X.";
		}
		else if (ch[i] == '8')
		{
			cout << "XXX.";
		}
		else if (ch[i] == '9')
		{
			cout << "XXX.";
		}
	}
	if (ch[n - 1] == '0')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '1')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '2')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '3')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '4')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '5')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '6')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '7')
	{
		cout << "..X" << endl;
	}
	else if (ch[n - 1] == '8')
	{
		cout << "XXX" << endl;
	}
	else if (ch[n - 1] == '9')
	{
		cout << "XXX" << endl;
	}

	system("pause");
	return 0;
}

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