Created
November 13, 2014 13:10
-
-
Save anuradhawick/123befdb776a38da8c42 to your computer and use it in GitHub Desktop.
Euler4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef int bool; | |
#define true 1 | |
#define false 0 | |
void main(){ | |
char a[7]; | |
int i,j,p,m=100; | |
for(i=100;i<1000;i++){ | |
for(j=100;j<1000;j++){ | |
p = i*j; | |
sprintf(a,"%d",p); | |
if(palindrome(a,length(a))) { | |
if(m<p) m=p; | |
} | |
} | |
} | |
printf("%d",m); | |
} | |
bool palindrome(char * A1,int size){ | |
int i=0; | |
for(i=0;i<size/2;i++){ | |
if(A1[i] != A1[size-i-1]) return false; | |
} | |
return true; | |
} | |
int length(char * array){ | |
int len=0,i=0; | |
while(1){ | |
if(array[i]=='\0') return len; | |
len++; | |
i++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment