[ create a new paste ] login | about

Link: http://codepad.org/6UL5hxyw    [ raw code | output | fork ]

C, pasted on Nov 4:
#include <stdio.h>
#include <string.h>

int isPalindrome(char st[]){
  int i, len=strlen(st);
  char *p;
  p = &st[len-1];

  for(i=0;i<len/2;i++)
    if(st[i] != *p--) return 0;

  return 1;
}

int main(){
  char str[256];
  printf("文字列を入力してください:");
  gets(str);

  if(isPalindrome(str))
    printf("その文字列は回文です。\n");
  else
    printf("その文字列は回文ではありません。\n");

  return 0;
}


Output:
1
文字列を入力してください:その文字列は回文ではありません。


Create a new paste based on this one


Comments: