弧
俱计いㄒ153骸ì13 + 53 + 33 = 153硂妓计嘿ぇArmstrong计刚糶祘Αт┮Τ计Armstrong计
秆猭
Armstrong计碝тㄤ龟碞琌拜盢计だ秆计计κ计......硂璶ㄏノ埃猭籔緇计笲衡碞ㄒ块 inputabc玥
a = input / 100
b = (input%100) / 10
c = input % 10
龟
#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; }
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(); } }
|