样例过,80分,求解
查看原帖
样例过,80分,求解
778382
wch666楼主2023/5/20 20:40
#include<bits/stdc++.h>
using namespace std;
bool zspd(int a)
{
	bool flag = true;
	for(int j=2; j<=sqrt(a); j++)
	{
		if(a%j == 0)
		{
			flag = false;
			{
				break;
				return false;
			}
		}
	}
	if(flag)
		return true;
}
int n;
int main()
{
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	for(int i=0; i<n; i++)
	{
		bool t=zspd(a[i]);
		if(t == 1)
			cout<<a[i]<<" ";
	} 
	return 0; 
}
2023/5/20 20:40
加载中...