I. Palindrome – Codeforces Problem Solution in C

Disclaimer: Make sure you tried enough before checking the solution

Problem: https://codeforces.com/group/MWSDmqGsZm/contest/219856/problem/I

#include<stdio.h>
#include<string.h>
int main(){
	char a[10000],f=0;
	int n,i,j;
	scanf("%s",a);
    for(i=0,j=strlen(a)-1;i<strlen(a);i++,j--){
        if(a[i]==a[j]) f =1;
        else{
            f =0;
            break;
        }
    }
    if(f==1) printf("YES");
    else if(f==0) printf("NO");

	return 0;
}

Assiut University Training – Newcomers Solution String

Leave a Comment