fork download
  1. #include <stdio.h>
  2.  
  3. int isPalindrome(char s[],char t[]){
  4. int i,j;
  5. for(i=0;s[i]!='\0';i++){//文字数をカウント
  6. }
  7. int len=i;//lenにsの文字列の文字数を格納
  8. for(j=0;j<len;j++){
  9. t[j]=s[len-1-j];//tに後ろ向きで文字列を格納していく
  10. }
  11. t[j]='\0';//tの文字列に終端文字をつける
  12.  
  13. for(i=0;s[i]!='\0';i++){
  14. if(s[i]!=t[i]){//もしs,tの文字列が一致しなかったら0を返す
  15. return 0;
  16. }
  17. }
  18. return 1;//ifに引っかからなかったら最後まで行ったということなので一致判定で1を返す
  19. }
  20.  
  21. int main(void) {
  22. // your code goes here
  23. char s[100];
  24. char t[100];
  25. scanf("%s",s);
  26. int x=isPalindrome(s,t);
  27. printf("%d",x);
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5320KB
stdin
abcbz
stdout
Standard output is empty