1 条题解

  • 0
    @ 2025-10-10 15:45:27

    C :

    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include<ctype.h>
    char a[101];
    int huiWen(int x)
    {
        int h=0;
        int l=x;
        while(x>0)
        {
            h=h*10+x%10;
            x/=10;
        }
        if(l==h) return 1;
        else return 0;
    }
    int main()
    {
        gets(a);
        int b=atoi(a);
        if(huiWen(b)==1) printf("TRUE");
        else printf("FALSE");
        return 0;
    }
            
    
    

    C++ :

    #include <iostream>
    #include <cstring>
    using namespace std;
    int main(){
    	char s[120];
    	gets(s);
    	bool f=true;
    	char t;
    	int i;
    	for(i=0;i<(strlen(s)-1)/2;i++){
    		if(s[i]!=s[strlen(s)-i-2]){
    			f=false;
    			break;
    		}
    	}
    	if(f==true){
    		cout<<"TRUE"<<endl;
    	}
    	else{
    		cout<<"FALSE"<<endl;
    	}
    }
    

    Pascal :

    var s,a,x:string;
    b,i:longint;
    begin
    read(s);
    b:=length(s);
    b:=b-1;
    for i:=1 to b do
    x:=x+s[i];
    for i:=b downto 1 do
    a:=a+s[i];
    if a=x then write('TRUE')
    else write('FALSE');end.
    

    Java :

    import java.util.Scanner;
    public class Main {
    	public static void main(String[] args) {
    		Scanner in = new Scanner(System.in);
    		String s = in.nextLine();
    		char[]a = s.toCharArray();
    		int x1=a[0];
    		int x2=a[1];
    		int x3=a[2];
    		int x4=a[3];
    		int x5=a[4];
    		if((x1==x5&&x2==x4&&x1+2==x3&&x2+1==x3)
    			||(x1==x5&&x2==x4&&x1-2==x3&&x2-1==x3)){
    			System.out.println("TRUE");
    		}else
    			System.out.println("FALSE");
    	}
    }
    

    Python :

    a=input()
    b=[]
    c=[]
    for i in a:
      b.append(i)
    i=len(b)-2
    while i>=0:
      c.append(b[i])
      i=i-1
    c.append('.')
    if c==b:
      print('TRUE')
    else:
      print("FALSE")
    
    • 1

    信息

    ID
    93
    时间
    1000ms
    内存
    512MiB
    难度
    10
    标签
    递交数
    6
    已通过
    4
    上传者