当前位置:网站首页>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;
} 边栏推荐
- [Maya] the error of importing Maya into Metahuman
- Laravel artisan common commands
- uTools
- [Chongqing Guangdong education] Tianshui Normal University universe exploration reference
- 城市选择器组件实现原理
- 三分钟学会基础k线图知识
- Design and implementation of radio energy transmission system
- 如何远程、在线调试app?
- [Floyd] post disaster reconstruction
- Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
猜你喜欢

It's already 30. Can you learn programming from scratch?

现货黄金分析的技巧有什么呢?

6-2 vulnerability exploitation - inevitable problems of FTP

TSINGSEE青犀平台如何实现同一节点同时播放多个视频?

Exclusive delivery of secret script move disassembly (the first time)

微信小程序中使用tabBar

跨域?同源?一次搞懂什么是跨域

Learning note 24 - multi sensor post fusion technology

开发工具创新升级,鲲鹏推进计算产业“竹林”式生长

Leetcode, 3 repeatless longest subsequence
随机推荐
Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
Bat Android Engineer interview process analysis + restore the most authentic and complete first-line company interview questions
II Basic structure of radio energy transmission system
卷積神經網絡(包含代碼與相應圖解)
学习笔记2--高精度地图定义及价值
浅浅了解Servlet
Using tabbar in wechat applet
np.where 和 torch.where 用法
Learning note 24 - multi sensor post fusion technology
Brief introduction to the development of mobile network
[disease detection] realize lung cancer detection system based on BP neural network, including GUI interface
分卷压缩,解压
Matlab uses audioread and sound to read and play WAV files
MPLS experiment operation
Convolutional neural network (including code and corresponding diagram)
The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
Implementation principle of city selector component
Electronic Association C language level 1 33, odd even number judgment
We should make clear the branch prediction
成功实现边缘编码需要了解的六大经验教训