1 条题解

  • 0
    @ 2025-9-10 0:05:05

    C++ :

    #include<stdio.h>
    #include<string.h>
    int main(){
    	char str[250];
    	while(scanf("%s",str)!=EOF){
    		int len=strlen(str);
    		int flag=1;
    		for(int i=0,j=len-1;i<j;i++,j--){
    			if(str[i]!=str[j]){
    				flag=0;
    				break;
    			}
    		}
    		if(flag==0){
    			printf("N\n"); 
    		}else{
    			printf("Y\n");
    		}
    	}
    	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

    信息

    ID
    2571
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者