From Gossip@caterpillar

Algorithm Gossip: ﹊吹Ё计

弧

俱计いㄒ153骸ì13 + 53 + 33 = 153硂妓计嘿ぇArmstrong计刚糶祘Αт┮Τ计Armstrong计

秆猭

Armstrong计碝тㄤ龟碞琌拜盢计だ秆计计κ计......硂璶ㄏノ埃猭籔緇计笲衡碞ㄒ块 inputabc玥
a = input / 100
b = (input%100) / 10
c = input % 10

龟

  • C
#include <stdio.h> 
#include <time.h>
#include <math.h>

int main(void) {
int a, b, c;
int input;

printf("碝тArmstrong计\n");

for(input = 100; input <= 999; input++) {
a = input / 100;
b = (input % 100) / 10;
c = input % 10;
if(a*a*a + b*b*b + c*c*c == input)
printf("%d ", input);
}

printf("\n");

return 0;
}

  • Java
public class Armstrong {
public static void main(String[] args) {
System.out.println("碝тArmstrong计");

for(int i = 100; i <= 999; 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)
System.out.print(i + " ");
}

System.out.println();
}
}