C++三级函数

多天未见,甚是想念

纯粹素数

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
long long n;
bool hh(int);
int main()
{
	for(int i=1000;i<=3000;i++)
	{
		int a=i%1000;
		int b=i%100;
		int c=i%10;
		if(hh(i)==true&&hh(a)==true&&hh(b)==true&&hh(c)==true){
			cout<<i<<endl;
		}
	}
	return 0;
}
bool hh(int a){
	if(a==1){
		return false;
	}
	if(a==2){
		return true;
	}
	for(int i=2;i*i<=a;i++){
		if(a%i==0){
			return false;
		}
	}
}

求一个三位数

cpp 复制代码
include<bits/stdc++.h>
using namespace std;
int n;
int hs(int);
int main()
{
	int u;
	for(int i=100;i<=999;i++)
	{
		int a=i/100%10;
		int b=i/10%10;
		int c=i/10;
		int d=hs(a);
		int e=hs(b);
		int f=hs(c);
		if(d+e+f==i)
		{
			u=i;
			break;
		}
	}
	cout<<u;
	return 0;
}
int hs(int z){
	int h;
	for(int i=1;i<=z;i++)
	{
		h=h*i;
	}
	return h;
}

亲密数对我尽力了

回文数个数

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
int n;
void hs(int);
int main()
{
	
	hs();
	return 0;
}
void hs()
{
	int y,h=0,sum=0;
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		int a=i;
		y=i;
		while(a!=0){
			h=h*10+a%10;
			a=a/10;
		}
		if(h==y){
			sum++;
		}
	}
	cout<<sum;
	return;
}

歌德巴赫猜想

相关推荐
好开心啊没烦恼3 分钟前
Python 数据分析:numpy,抽提,整数数组索引与基本索引扩展(元组传参)。听故事学知识点怎么这么容易?
开发语言·人工智能·python·数据挖掘·数据分析·numpy·pandas
岁忧10 分钟前
(LeetCode 面试经典 150 题 ) 58. 最后一个单词的长度 (字符串)
java·c++·算法·leetcode·面试·go
BIYing_Aurora18 分钟前
【IPMV】图像处理与机器视觉:Lec13 Robust Estimation with RANSAC
图像处理·人工智能·算法·计算机视觉
future14121 小时前
C#学习日记
开发语言·学习·c#
码农编程录1 小时前
【c/c++3】类和对象,vector容器,类继承和多态,systemd,std&boost
c++
king_harry1 小时前
Java程序-OceanBase Connector/J 示例
开发语言
martian6652 小时前
支持向量机(SVM)深度解析:从数学根基到工程实践
算法·机器学习·支持向量机
孟大本事要学习2 小时前
算法19天|回溯算法:理论基础、组合、组合总和Ⅲ、电话号码的字母组合
算法
傻啦嘿哟2 小时前
Python 办公实战:用 python-docx 自动生成 Word 文档
开发语言·c#
翻滚吧键盘2 小时前
js代码09
开发语言·javascript·ecmascript