0
点赞
收藏
分享

微信扫一扫

C语言求水仙花数

kmoon_b426 2022-04-19 阅读 44
c语言
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void check_count();
void combineNum(int x, int y, int z,int num);
void printDiamond(int x, int y);
void purchaseChicken();
float calculatePi();
void primeJudge();
void perfectJudge();
void intimacyNumber();
void automorphic();
void narcissisticNumber();
int main() {
	narcissisticNumber();
	return 0;
}


//水仙花数
void narcissisticNumber() {
	int num = 100;
	int onesPlace = 0, tensPlace = 0, hundredsPlace = 0;
	while (num<1000) {
		onesPlace = num % 10;
		tensPlace = (num%(int)1e2)/10;
		hundredsPlace = num / (int)1e2;

		if (num==(pow(onesPlace,3)+pow(tensPlace,3)+pow(hundredsPlace,3))) {
			printf("%d=%d^3+%d^3+%d^3\n",num,onesPlace,tensPlace,hundredsPlace);
		}
		num++;
	}
}
举报

相关推荐

求水仙花数

c语言:水仙花数

C语言 水仙花数

水仙花数——C语言

c水仙花数

0 条评论