47(2023.12.14)好多水题,懒得发

47(2023.12.14)好多水题,懒得发_第1张图片

#define _CRT_SECURE_NO_WARNINGS 1
#include
int test(int x)
{
	if (x == 2)return 1;
	else if (x > 2)
	{
		for (int i = 2;i * i <= x;i++)
		{
			if (x % i == 0)
			{
				return 0;
			}
		}
	}
	return 1;
}
int main()
{
	int arr[200] = {0};
	int n;
	int times = 0;
	scanf("%d", &n);
	for (int i = 2;i <= n;i++)
	{
		if (n % i == 0)
		{
			if (test(i) == 1)
			{
				arr[times] = i;
				times++;
			}
		}
	}
	if (times == 0)printf("%d", n);
	else
	{
		for (int i = 0;i < times;i++)
		{
			printf("%d", arr[i]);
			if (!(arr[i + 1] == 0))
			{
				printf(" ");
			}
		}
	}
	return 0;
}

 47(2023.12.14)好多水题,懒得发_第2张图片

#define _CRT_SECURE_NO_WARNINGS 1
#include

int main()
{
	long long arr[100] = { 0 };
	int n;
	long long x;
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%lld", &x);
		arr[i] = x;
	}
	for (int i = (n - 1);i >= 0;i--)
	{
		printf("%lld\n", arr[i]);
	}
	return 0;
}

47(2023.12.14)好多水题,懒得发_第3张图片

#define _CRT_SECURE_NO_WARNINGS 1
#include

int main()
{
	long long arr1[100] = { 0 };
	long long arr2[100] = { 0 };
	int n;
	long long x;
	scanf("%d", &n);
	int times1 = 0;
	int times2 = 0;
	for (int i = 0;i < n;i++)
	{
		scanf("%lld", &x);
		if (x % 2 == 0)
		{
			arr2[times2] = x;
			times2++;
		}
		else
		{
			arr1[times1] = x;
			times1++;
		}
	}
	for (int i = 0;i < times1;i++)
	{
		printf("%lld\n", arr1[i]);
		
	}
	for (int i = 0;i < times2;i++)
	{
		printf("%lld\n", arr2[i]);
		
	}
	return 0;
}

47(2023.12.14)好多水题,懒得发_第4张图片

#include
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int arr[100]={0};
	for(int i=0;i

 47(2023.12.14)好多水题,懒得发_第5张图片

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