Given a list of strings, find a string whose reverse is in the list and return the middle character of it. The length of the string is guaranteed to be "odd".
Implementation:
Implementation:
#include <stdio.h> #define MAXN 100 #define MAXS 16 int main() { int N,i,j,size,m,k,n; char mid; char str[MAXN][MAXS],arr[MAXS]; scanf("%d",&N); for(i=0;i<N;i++) { scanf("%s",str[i]); } for(i=0;i<N;i++) { for(j=1;j<N;j++) { k=strlen(str[j]); for(m=k,n=0;m>0;m--,n++) { arr[n]=str[j][m]; } arr[n-1]='\0'; if(strcmp(str[i],arr)) { size=strlen(str[i]); mid=str[i][size/2]; } } } printf("%d %c",size,mid); return 0; }