当前位置:网站首页>C language 3-7 daffodils (enhanced version)
C language 3-7 daffodils (enhanced version)
2022-07-02 01:43:00 【Bathe in the four seasons】
Output narcissus number . Enter a positive integer (3≤ n ≤7), Output all n Number of daffodils . The number of Narcissus refers to a n Positive integer , Its digits n The sum of the powers is equal to itself . for example 153 The cube sum of each digit of 1^3+5^3+3^3=153.
attach : Daffodils number is also known as Armstrong number .
The number of daffodils of the three is 4 individual :153,370,371,407;
The number of four leaf roses in four digits is 3 individual :1634,8208,9474;
There are five pointed stars in five digits 3 individual :54748,92727,93084;
The six digit number is only 1 individual :548834;
There are seven stars in the Big Dipper 4 individual :1741725,4210818,9800817,9926315;
There are eight immortals in total 3 individual :24678050,24678051,88593477.
example : Input n=4, Output 1634,8208,9474
#include<stdio.h>// Daffodil number enhanced version
#include<math.h>
int main(void)
{
int n,i,j,x,k;
double sum=0;
printf("Enter n:");
scanf("%d",&n);
printf("%d The number of daffodils is :",n);
if(n<3||n>7){
printf("Invalid!\n");
}
else {
for(i=100;i<pow(10,n);i++)// except n=5, The rest are normal , There will be more 4150,4151, Need to increase digit judgment ( Already added )
{
j=i;
sum=0;
while(j>0){
x=j%10;
sum+=pow(x,n);
j=j/10;
}
if((sum==i)&&(sum>pow(10,n-1)&&sum<pow(10,n+1)))
{
printf("%.lf\t",sum);
}
}
}
return 0;
} 边栏推荐
- [image enhancement] vascular image enhancement based on frangi filter with matlab code
- Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
- What is AQS and its principle
- Study note 2 -- definition and value of high-precision map
- II Basic structure of radio energy transmission system
- Architecture evolution from MVC to DDD
- Exclusive delivery of secret script move disassembly (the first time)
- Just using the way and method of consuming the Internet to land and practice the industrial Internet will not bring long-term development
- Brief description of grafana of # yyds dry goods inventory # Prometheus
- 学习笔记24--多传感器后融合技术
猜你喜欢

【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享

Six lessons to be learned for the successful implementation of edge coding

Finally got byte offer, 25-year-old inexperienced experience in software testing, to share with you

Edge extraction edges based on Halcon learning_ image. Hdev routine

Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage

Learn basic K-line diagram knowledge in three minutes

浅浅了解Servlet

The technology boss is ready, and the topic of position C is up to you

Three core problems of concurrent programming

卷积神经网络(包含代码与相应图解)
随机推荐
电子协会 C语言 1级 32、计算2的幂
牛客网——华为题库(51~60)
Implementation principle of city selector component
电子协会 C语言 1级 33 、奇偶数判断
分卷压缩,解压
Cross domain? Homology? Understand what is cross domain at once
ES6 new method of string
Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
5g/4g pole gateway_ Smart pole gateway
迁移云计算工作负载的四个基本策略
KS006基于SSM实现学生成绩管理系统
How can the tsingsee Qingxi platform play multiple videos at the same time on the same node?
Based on configured schedule, the given trigger will never fire
uTools
遷移雲計算工作負載的四個基本策略
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
城市选择器组件实现原理
Ubuntu20.04 PostgreSQL 14 installation configuration record
Four basic strategies for migrating cloud computing workloads