文字列が回文であるか、ライブラリ string.h を使用していないかを教えてくれるプログラムを実行する必要があります。次のコードを書きましたが、出力は常に「回文」です
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char a[100],b[100];
int i,k;
printf("Type the string \n");
gets(a);
k=strlen(a);
for(i=0;i<strlen(a);i++)
{
a[i]=b[k];
k--;
} //at the end of this code the string "b" should be the reverse of "a"
k=strcmp(a,b);
if (k!=0) //here I check if a=b or not
{printf("palindrome");}
else
{printf("not palindrome");}
getch();
return 0;
}
例: 入力が「非」の場合、出力は「回文」である必要があり、入力が「船」の場合、出力は「回文ではない」である必要があります。誰が間違っているかを見つけるのを手伝ってくれますか?