kiểm tra kí tự có đối xứng hay không ?

PHOTO EMBED

Thu Aug 19 2021 03:20:49 GMT+0000 (Coordinated Universal Time)

Saved by @_Ryan_ #c

#include<stdio.h>
#include<stdbool.h>
#include<conio.h>
#include<math.h>
#include<string.h>

void main()
{
   int temp, i, j;
   temp = 0;
   char chars[20];

    printf("enter chars : ");
    gets(chars);

    for(i = 0, j = strlen(chars)-1; i < j; i++, j--)
    {
        if(chars[i] != chars[j])
        {
            temp = 1;
            break;
        }
    }

     if ( temp == 0)
     {
         printf("symmetric chain");
     }
     else
     {
        printf("not symmetric chain");
     }

    getch();

}
content_copyCOPY