fork download
  1. # include <stdio.h>
  2. //回英語の判定(前から順にみた文字列と後ろからが一致していればよい
  3. int isPalindrome(char s[]){
  4. //回文になっているとき1を返す
  5. //回文になっていないとき0を返す
  6. int i=0, j;
  7. for(j=0; s[j+1]!='\0'; j++) //とりあえずjは一番最後まで
  8. while(i<=j){ //回文になっていないときの条件
  9. if(s[i++]!=s[j--]) //i++で進めj--で戻す
  10. return 0;
  11. }
  12. return 1;
  13. }
  14.  
  15.  
  16. int main(){
  17. char s[100];
  18. scanf("%s",s);
  19. printf("%s -> %d\n",s,isPalindrome(s));
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
 -> 1