1 solutions
-
0
C :
#include<stdio.h> #include<string.h> int main() { int i,length,flag; char s[256]; while(scanf("%s",s)!=EOF) { flag=1; length=strlen(s); for(i=0;i<length/2;i++) { if(s[i]!=s[strlen(s)-i-1]) { flag=0; printf("N\n"); break; } } if(flag) printf("Y\n"); } return 0; }C++ :
#include <iostream> #include <string> using namespace std; int main() { int i,j,len,tag=0; string s; cin>>s; len=s.length(); for(i=0;i<=len/2;++i) if(s[i]!=s[len-i-1]) { tag=1; break; } if(tag==1) cout<<'N'; else cout<<'Y'; return 0; }Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String c = in.nextLine(); if(issame(c)==true) System.out.println("Y"); else System.out.println("N"); } public static boolean issame(String c){ return new StringBuffer(c).reverse().toString().equals(c); } }
- 1
Information
- ID
- 19556
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By