当前位置:网站首页>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;
}
边栏推荐
- [IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
- [IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
- Four basic strategies for migrating cloud computing workloads
- uTools
- matlab 使用 audiorecorder、recordblocking录制声音,play 播放声音,audiowrite 保存声音
- No converter found for return value of type: class
- Android high frequency network interview topic must know and be able to compare Android development environment
- 人工智能在网络安全中的作用
- II Basic structure of radio energy transmission system
- Using tabbar in wechat applet
猜你喜欢
Basic concepts of machine learning
MPLS experiment operation
The technology boss is ready, and the topic of position C is up to you
三分钟学会基础k线图知识
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
Game thinking 15: thinking about the whole region and sub region Services
6-2漏洞利用-ftp不可避免的问题
2022年6月国产数据库大事记
How can I batch produce the same title for the video?
5g/4g pole gateway_ Smart pole gateway
随机推荐
迁移云计算工作负载的四个基本策略
[IVX junior engineer training course 10 papers] 06 database and services
Modeling essays series 124 a simple coding method
It's already 30. Can you learn programming from scratch?
Feature extraction and detection 16 brisk feature detection and matching
Design and implementation of radio energy transmission system
Laravel artisan 常用命令
Ubuntu20.04 PostgreSQL 14 installation configuration record
Makefile simple induction
matlab 使用 resample 完成重采样
Learn about servlets
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
D discard the virtual recovery method
如何远程、在线调试app?
uTools
遷移雲計算工作負載的四個基本策略
【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面
Android high frequency network interview topic must know and be able to compare Android development environment
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
并发编程的三大核心问题