Problem 4 solution
More...
#include <stdio.h>
|
int | is_palindromic (unsigned int n) |
| Check if number is palindromic.
|
|
int | main (void) |
| Main function.
|
|
◆ is_palindromic()
int is_palindromic |
( |
unsigned int |
n | ) |
|
Check if number is palindromic.
- Parameters
-
- Returns
- 1 if palindromic
-
0 if not palindromic
13{
14 unsigned int reversed = 0, t = n;
15
16 while (t > 0)
17 {
18 reversed = 10 * reversed + (t % 10);
19 t /= 10;
20 }
21 return reversed == n;
22}
◆ main()
Main function.
26{
27 unsigned int i, j, max = 0;
28 for (i = 100; i <= 999; i++)
29 {
30 for (j = 100; j <= 999; j++)
31 {
32 unsigned int p = i * j;
34 {
35 max = p;
36 }
37 }
38 }
39 printf("%u\n", max);
40 return 0;
41}
int is_palindromic(unsigned int n)
Check if number is palindromic.
Definition sol.c:12