1 条题解

  • 0
    @ 2026-2-10 16:08:31

    C :

    #include<stdio.h>
    int main()
    {
    	int a,b,c,d,n,e;
    	scanf("%d",&n);
    	a=n%10;
    	b=(n%100)/10;
    	c=(n%1000)/100;
    	d=(n%10000)/1000;
    	e=n/10000;
    	if(e != 0)
    	{
    		printf("5\n%d%d%d%d%d",a,b,c,d,e);
    	}
    	else if(d  != 0)
    	{
    		printf("4\n%d%d%d%d",a,b,c,d);
    	}
    	else if(c != 0)
    	{
    		printf("3\n%d%d%d",a,b,c);
    	}
    	else if(b !=0)
    	{
    		printf("2\n%d%d",a,b);
    	}
    	else if(a !=0)
    	{
    		printf("1\n%d",a);
    	}
    	return 0;
    }
    

    C++ :

    #include <iostream>
     using namespace std;
     int  main()
     {
         int n,a,b,c,d,e;
         cin>>n;
         a=n%10;
    	 b=n/10%10;
    	 c=n/100%10;
    	 d=n/1000%10;
    	 e=n/10000%10;
    	 if(e>0)
    	 {
    	 	cout<<"5"<<endl;
    	 	cout<<a<<b<<c<<d<<e;
    	 }
    	 else if(e==0&&d>0)
    	 {
    	 	cout<<"4"<<endl;
    	 		cout<<a<<b<<c<<d;
    	 }
    	  else if(e==0&&d==0&&c>0)
    	 {
    	 	cout<<"3"<<endl;
    	 	cout<<a<<b<<c;
    	 }
    	  else if(e==0&&d==0&&c==0&&b>0)
    	 {
    	 	cout<<"2"<<endl;
    	 	cout<<a<<b;
    	 }
    	 else
    	 {
    	 	cout<<"1"<<endl;
    	 	cout<<a;
    	 }
         return 0;
     } 
    

    Java :

    import java.util.Scanner;
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = a;
            int n = 0;
            while (a>0){
                a/=10;
                n++;
            }
            System.out.println(n);
            for (int i = 0 ; i < n ;i++){
                System.out.print(b % 10);
                b/=10;
            }
        }
    }
    
    

    Python :

    # coding=utf-8
    #python2
    x = int(input())
    if(x>9999):
        y = 5;
    else:
        if (x > 999):
            y = 4;
        else:
            if (x > 99):
                y = 3;
            else:
                if (x > 9):
                    y = 2
                else:
                    y = 1
    print(y)
    a=x//10000
    b=x//1000%10
    c=x//100%10
    d=x//10%10
    e=x%10
    if y==1:
        print(e)
    if y==2:
        print('%d%d'%(e,d))
    if y==3:
        print('%d%d%d'%(e,d,c))
    if y==4:
        print('%d%d%d%d'%(e,d,c,b))
    if y==5:
        print('%d%d%d%d%d'%(e,d,c,b,a))
    

    C# :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Security.Cryptography;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApp2
    {
        internal class Program
        {
            static void Main()
            {
                string a = Console.ReadLine();
                Console.WriteLine(a.Length);
                for (int i = 0; i <= a.Length - 1; i++)
                {
                    Console.Write(a[a.Length - i - 1]);
                    
    
                }
    
                Console.ReadKey();
            }
        }
    }
    
    • 1

    信息

    ID
    29
    时间
    1000ms
    内存
    128MiB
    难度
    2
    标签
    递交数
    0
    已通过
    0
    上传者