SHOW:
|
|
- or go back to the newest paste.
| 1 | /* C programme to check if a string is palindrome or not */ | |
| 2 | #include<stdio.h> | |
| 3 | #include<string.h> | |
| 4 | int main(void) | |
| 5 | {
| |
| 6 | char a[999]; | |
| 7 | gets(a); | |
| 8 | int x=strlen(a); | |
| 9 | int counter=0; | |
| 10 | int i; | |
| 11 | for(i=0;i<=x;i++) | |
| 12 | {
| |
| 13 | if(a[i]==a[x-1]) | |
| 14 | {
| |
| 15 | counter++; | |
| 16 | x--; | |
| 17 | } | |
| 18 | } | |
| 19 | if(i==counter) | |
| 20 | {
| |
| 21 | printf("YES\n");
| |
| 22 | } | |
| 23 | else | |
| 24 | {
| |
| 25 | printf("NO\n");
| |
| 26 | } | |
| 27 | return 0; | |
| 28 | } | |
| 29 | /* | |
| 30 | Check if a string is palindrome or not. | |
| 31 | Sample input: ulala | |
| 32 | Sample output: NO | |
| 33 | ||
| 34 | Sample input: abcba | |
| 35 | Sample output: YES | |
| 36 | */ |