judge return character
pascal:
var number :string; n,i:integer; flag:boolean; begin readln(number); n:=length(number); flag:=true; for i:=1 to trunc( (n+1)/2 ) do if number[i]<> number[n+1-i] then begin flag:=false; break; end; writeln(flag); end.
c:
#include <stdio.h> #include <stdbool.h> int str_length(char str[]) { int len,i; len=0; i=0; while(str[i]) { i++; len++; } return len; } int main(void) { char str[1000000]; int n,i; bool flag; scanf("%s",str); n=str_length(str); flag=true; for( i=1-1;i<=((n+1)/2 -1);i++ ) { if(str[i]!= str[n-1-i] ) { flag=false; break; } } if(flag) printf("true"); else printf("false"); }