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

2023-12-15 05:00:01

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
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;
}

?

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

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

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

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

#include<stdio.h>
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int arr[100]={0};
	for(int i=0;i<n;i++)
	{
		arr[i]=i+1;
	}
	int start=-1;
	int len=n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<k;j++)
		{
			start++;
			if(start==len)start=0;
			while(arr[start]==0)
			{
				start++;
				if(start==len)start=0;
			}
		}
		printf("%d\n",arr[start]);
		arr[start]=0;
	}
	return 0;
}

?

文章来源:https://blog.csdn.net/weixin_72770922/article/details/134962055
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。