fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int Test_Armstrong(int zahl){
  8. int rest, summe=0, n=0, temp;
  9.  
  10. temp = zahl;
  11.  
  12. while (temp != 0){
  13. n++;
  14. temp=temp/10;
  15. }
  16.  
  17. temp = zahl;
  18.  
  19. while (temp !=0){
  20. rest = temp%10;
  21. summe = summe + pow(rest,n);
  22. temp = temp/10;
  23. }
  24.  
  25. if (summe == zahl)
  26. return 1;
  27. else
  28. return 0;
  29. }
  30.  
  31. int main()
  32. {
  33. int i;
  34.  
  35. for (i=0; i<=1000; i++){
  36. if (Test_Armstrong(i) == 1)
  37. cout << i << endl;
  38. }
  39.  
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9
153
370
371
407