Algorithms_in_C  1.0.0
Set of algorithms implemented in C.
sol.c File Reference

Problem 4 solution More...

#include <stdio.h>
Include dependency graph for sol.c:

Functions

int is_palindromic (unsigned int n)
 
int main (void)
 

Detailed Description

Problem 4 solution

Function Documentation

◆ is_palindromic()

int is_palindromic ( unsigned int  n)

Check if number is palindromic

Parameters
[in]nnumber to check
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()

int main ( void  )

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;
33  if (is_palindromic(p) && p > max)
34  {
35  max = p;
36  }
37  }
38  }
39  printf("%u\n", max);
40  return 0;
41 }
Here is the call graph for this function:
is_palindromic
int is_palindromic(unsigned int n)
Definition: sol.c:12
max
#define max(a, b)
Definition: kohonen_som_topology.c:31