#include<stdio.h>
int main()
{
int x,a,b,c;
scanf("%d",&x);
a = x % 10;
b = (x / 10) % 10;
c = (x / 10) / 10;
if (x == a * a * a + b * b * b + c * c * c)
printf("%d是水仙花数",x);
else
printf("%d不是水仙花数",x);
return 0;
#include<stdio.h>
#include<math.h>
int main()
{
int i = 0;
for (i = 100; i<1000; i++)
{
int n = 0;
int temp = i;
while (temp)
{
n++;
temp = temp / 10;
}
temp = i;
int sum = 0;
while (temp)
{
sum = sum + pow(temp % 10, n);
temp = temp / 10;
}
if (sum == i)
{
printf("%d ", i);
}
}
}
int main()
{
int i, b, s, g;
for (i = 100; i < 1000; i++) {
b = i / 100;
s = i / 10 % 10;
g = i % 10;
if ((b * b * b + s * s * s + g * g * g )== i) {
printf("%d\n", i);
}
}
#include <stdio.h>
int main(){
int i,b,s,g;
for(i=100;i<1000;i++){
b = i/100;
s = i/10%10;
g = i%10;
if((b*b*b + s*s*s +g*g*g)==i){
printf("%d ",i);
}
}
}
int main() {
int a, b, c,num;
for (int i = 100; i < 1000; i++) {
a = i / 100;
c = (i-a*100)%10;
b = (i - a * 100) / 10;
num = a * a * a + b * b * b + c * c * c;
if (i == num) {
printf("%d ", num);
}
}
return 0;
}
int main() {
int a, b, c,num;
for (int i = 100; i < 1000; i++) {
a = i / 100;
c = (i-a*100)%10;
b = (i - a * 100) / 10;
num = a * a * a + b * b * b + c * c * c;
if (i == num) {
printf("%d ", num);
}
}
#include <stdio.h>
#include <math.h>
int main() {
for (int i = 100; i < 1000; i++) {
int num = i;
int a = num % 10;
num /= 10;
int b = num % 10;
num /= 10;
int c = num % 10;
if (pow(a, 3) + pow(b, 3) + pow(c, 3) == i)
printf("%d是水仙花数\n",i);
int main()
{
for (int i = 100; i < 1000; i++)
{
int a = i / 100; // 百位数
int b = (i % 100) / 10; // 十位数
int c = i % 10; // 个位数
if (a * a * a + b * b * b + c * c * c == i)
{
printf("%d\n", i);
}
}
return 0;
}
#include <stdio.h>
#include <math.h>
int main(){
int a;
while (~scanf("%d",&a)) {
int b = a,sum = 0;
while (b!=0) {
sum = sum + pow(b%10,3);
b = b/10;
}
if(sum == a) printf("%d是水仙花数\n",a);
else printf("%d不是水仙花数\n",a);
}
return 0;
}
#include
int main(){
int a;
scanf("%d",&a);
int bai=a/100;
int shi=a%100/10;
int ge=a%100%10;
if(a==ge*ge*ge+shi*shi*shi+bai*bai*bai){
printf("Yes");
}else{
printf("No");
}
}
#include <stdio.h>
int main() {
int k = 100;
for (; k <= 999; ++k) {
int G = (k / 1) % 10;
int S = (k / 10) % 10;
int B = (k / 100) % 10;
if ((G * G * G) + (S * S * S) + (B * B * B) == k) {
printf("%d\n", k);
}
}
return 0;
}
#include <stdio.h>
#include <math.h>
int main(){
for (int i = 100; i < 1000; i++) {
int one = i%10;
int ten = (i/10)%10;
int hundred=i/100;
int value=(int)(pow(one,3)+ pow(ten,3)+ pow(hundred,3));
if(value==i){
printf_s("%d ",i);
}
}
return 0;
};
int main(){
int i;
for(i = 100; i <= 999; ++i){
int v = i;
int sum = 0;
while(v){
sum += pow(v % 10, 3);
v /= 10;
}
if(sum == i)
printf("%d\n", i);
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
int n;
int a = 152;
while (a<=999)
{
int w = a;
int s = 0;
while (w>0)
{
n = (w % 10) * (w % 10) * (w % 10);
s += n;
w= w/ 10;
}
if (a == s) {
printf("%d\n", a);
}
a++;
}
}
int main() {
int x, y, z, i;
for (i = 100; i < 1000; i++) {
x = i / 100;
y = i / 10 % 10;
z = i % 100 % 10;
if (i == pow(x, 3) + pow(y, 3) + pow(z, 3)) {
printf("%d\n", i);
}
}
return 0;
}
int main() {
int x, y, z, i;
for (i = 100; i < 1000; i++) {
x = i / 100;
y = i / 10 % 10;
z = i % 100 % 10;
if (i == pow(x, 3) + pow(y, 3) + pow(z, 3)) {
printf("%d\n", i);
}
}
return 0;
}
int main() {
int x, y, z, i;
for (i = 100; i < 1000; i++) {
x = i / 100;
y = i / 10 % 10;
z = i % 100 % 10;
if (i == x * x * x + y * y * y + z * z * z) {
printf("%d\n", i);
}
}
return 0;
}
#include<stdio.h>
int main(){
int ge,shi,bai;
for (int i = 100; i < 1000; ++i)
{
bai=i/100;
shi=(i/10)%10;
ge=i%10;
if (i==ge*ge*ge+shi*shi*shi+bai*bai*bai)
{
printf("%5d",i);
}
}
}
#include<stdio.h>
int main(){
int i;
int a,b,c;
for(i=100;i<=999;i++){
a=i%10;//个位
b=(i/10)%10;//十位
c=i/100;//百位
if((a*a*a+b*b*b+c*c*c)==i)
printf("%d\t",i);
}
}
int i;
for(i = 100;i < 1000;i++){
int num,bai,shi,ge;
bai = i / 100;
shi = (i % 100) / 10;
ge = i % 10;
num = pow(bai,3)+pow(shi,3)+pow(ge,3);
if(i==num){
printf("%d\n",num);
}
}
int main(){
int n, m, k;
for(int i = 100; i < 999; i++){
k = i % 10;
m = i / 10 % 10;
n = i / 100;
if(i == n * n * n + m * m * m + k * k * k)
printf("%d\n", i);
}
}
登录后提交答案