1 条题解

  • 0
    @ 2021-6-14 23:25:13

    C :

    #include<stdio.h>
    int main()
    {
    	int a,b,s,count,i,j,k;
    	scanf("%d%d",&a,&b);
    		printf("%d\n%d\n",a,b);
    		count=0;s=1;i=1;j=0;
    		while(b>0)
    		{
    			s=b%10;
    			if(s==0)
    			{
    				k=a;
    				while(k>0)
    				{
    					printf("0");
    					k=k/10;
    				}
    				printf("\n");
    				b=b/10;i=i*10;j++;
    			}
    			else
    			{
    				printf("%d\n",s*a);
    			    count+=s*a*i;
    			    b=b/10;i=i*10;
    			    j++;
    			}
    		}
    		if(j!=1)
    		    printf("%d\n",count);
    		printf("\n");
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    int main()
    {
    	int a,b,s,k,res;
    	int len = 0; 
    	scanf("%d%d",&a,&b);
    	char buf[10];
    	k = a;
    	while(k>0)
    		len++,k/=10;
    	sprintf(buf,"%%0%dd\n",len);
    	k = b;
    	printf("%d\n%d\n",a,b);
    	while(k>0)
    	{
    		s=k%10;
    		printf(buf,s*a);
    		k/=10;
    	}
    	if(b>=10)
    		printf("%d\n",a*b);
    	
    	//printf("%d",5);
    	return 0;
    }
    

    Pascal :

    var a,b,g,s:longint;
    begin
        readln(a,b);
        writeln(a);
        writeln(b);
        if b<10 then writeln(a*b)
        else
        begin
            g:=b mod 10;
            s:=b div 10;
            if g<>0 then
            begin
              writeln(a*g);
              writeln(a*s);
            end
            else
            begin
              writeln('00');
              writeln(a*s);
            end;
            writeln(a*b);
       end;
    end.
    
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    	public static void main(String[] args) {
    		Scanner sc=new Scanner(System.in);
    		int a=sc.nextInt(),b=sc.nextInt();
    		int temp1,temp2;
    		if((a+"").length()==2&&(b+"").length()==2){
    			System.out.println(a);
    			System.out.println(b);
    			temp1=Integer.parseInt((b+"").substring(1, 2))*a;
    			temp2=Integer.parseInt((b+"").substring(0, 1))*a;
    			if(temp1==0){
    				System.out.println("00");
    			}else{
    				System.out.println(temp1);
    			}
    			System.out.println(temp2);
    			System.out.println(temp1+temp2*10);
    		}else if((a+"").length()==1&&(b+"").length()==2){
    			System.out.println(a);
    			System.out.println(b);
    			temp1=Integer.parseInt((b+"").substring(1, 2))*a;
    			temp2=Integer.parseInt((b+"").substring(0, 1))*a;
    			if(temp1==0){
    				System.out.println("00");
    			}else{
    				System.out.println(temp1);
    			}
    			System.out.println(temp2);
    			System.out.println(temp1+temp2*10);
    		}else{
    			System.out.println(a);
    			System.out.println(b);
    			System.out.println(a*b);
    		}
    	}
    }
    

    C# :

    using System;
    
    namespace _200811乘法运算
    {
        class Class1
        {
            static void Main()
            {
                string[] s = Console.ReadLine().Split(' ');
                int a, b, c, d;
                a = int.Parse(s[0]);
                b = int.Parse(s[1]);
                Console.WriteLine(a);
                Console.WriteLine(b);
    
                if (b < 10)
                    Console.WriteLine(a * b);
                else
                {
                    c = b % 10; d = b / 10;
                    if (c != 0) Console.WriteLine(c * a);
                    else Console.WriteLine("0{0}", c * a);
                    Console.WriteLine(d * a);
                    Console.WriteLine(a * b);
                }
                Console.ReadLine();
            }
        }
    }
    
    
    • 1

    信息

    ID
    177
    时间
    1000ms
    内存
    125MiB
    难度
    10
    标签
    递交数
    4
    已通过
    1
    上传者