@@ -11,9 +11,14 @@ The Armstrong numbers are :
11
11
Rework regular Armstrong number solution to work in a range:
12
12
+ 1. Correct the input
13
13
+ 2. Find numbers inside a range
14
- 3. Test
15
- 4. Cppling
16
- 5. Add and push
14
+ + 3. Test:
15
+ Input: 1 and 912985153. Output:
16
+ 1 2 3 4 5 6 7 8 9 153 370 371 407 1634
17
+ 8208 9474 54748 92727 93084 548834 1741725
18
+ 4210818 9800817 9926315 24678050 24678051 472335975 534494836 912985153
19
+ 88593477 146511208
20
+ + 4. Cppling
21
+ + 5. Add and push
17
22
*/
18
23
19
24
#include <stdio.h>
@@ -25,11 +30,8 @@ int power(int base, int exponent);
25
30
int find_number_of_digits (int number );
26
31
int is_armstrong (int number , int number_of_digits );
27
32
void print_armstrong_in_range (int start , int end );
28
- void test (int number , int expected , int test_number );
29
-
30
33
31
34
int main () {
32
- // Regular run of the program
33
35
int start = input_start ();
34
36
if (start >= 0 ) {
35
37
int end = input_end ();
@@ -42,21 +44,8 @@ int main() {
42
44
return 0 ;
43
45
}
44
46
45
- // 0 - false, 1 - true
46
- void test (int number , int expected , int test_number ) {
47
- int number_of_digits = find_number_of_digits (number );
48
- int actual = is_armstrong (number , number_of_digits );
49
- if (actual == expected ) {
50
- printf ("Test #%d: number = %d, expected = %d, actual = %d\nSuccess\n" ,
51
- test_number , number , expected , actual );
52
- } else {
53
- printf ("Test #%d: number = %d, expected = %d, actual = %d\nFailed\n" ,
54
- test_number , number , expected , actual );
55
- }
56
- }
57
-
58
47
void print_armstrong_in_range (int start , int end ) {
59
- printf ("The Armstrong numbers are:\n" );
48
+ printf ("The Armstrong numbers are:\n" );
60
49
for (int i = start ; i <= end ; i ++ ) {
61
50
if (is_armstrong (i , find_number_of_digits (i ))) {
62
51
printf ("%d " , i );
0 commit comments