1 条题解

  • 0
    @ 2024-5-10 0:45:58

    C :

    #include<stdio.h>
     
    char t[][31]={" _     _  _     _  _  _  _  _ ","| |  | _| _||_||_ |_   ||_||_|","|_|  ||_  _|  | _||_|  ||_| _|"};
     
    int main()
    {
    	int a[4],i,j,k,n;
    	while(scanf("%d",&a[0])!=EOF)
    	{
    		for(i=1;i<4;i++)
    			scanf("%d",&a[i]);
    		for(k=0;k<3;k++)
    		{
    			for(i=0;i<4;i++)
    				for(j=3*a[i];j<3*a[i]+3;j++)
    					printf("%c",t[k][j]);
    			printf("\n");
    		}
    	}
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
     
    char t[][31]={" _     _  _     _  _  _  _  _ ","| |  | _| _||_||_ |_   ||_||_|","|_|  ||_  _|  | _||_|  ||_| _|"};
     
    int main()
    {
    	int a[4],i,j,k,n;
    	while(scanf("%d",&a[0])!=EOF)
    	{
    		for(i=1;i<4;i++)
    			scanf("%d",&a[i]);
    		for(k=0;k<3;k++)
    		{
    			for(i=0;i<4;i++)
    				for(j=3*a[i];j<3*a[i]+3;j++)
    					printf("%c",t[k][j]);
    			printf("\n");
    		}
    	}
    	return 0;
    }
    

    Pascal :

    program q1027;
    var a:array[1..4,1..1000]of integer; i,k,j,l:integer;
    begin
    while not eof do
    begin
    k:=k+1;
    for i:=1 to 3 do
    read(a[i,k]);
    readln(a[4,k]);
    end;
    for l:= 1 to k do
    begin
    for j:=1 to 3 do
    for i:=1 to 4 do
    begin
    if j=1 then begin
                if (a[i,l]=1) or (a[i,l]=4) then write('   ') else write(' _ ');
                end;
    if (j=1) and (i=4) then writeln;
    if j=2 then begin
                if (a[i,l]=1) or (a[i,l]=7) then write('  |');
                if (a[i,l]=2) or (a[i,l]=3) then write(' _|');
                if (a[i,l]=4) or (a[i,l]=8)or (a[i,l]=9) then write('|_|');
                if (a[i,l]=5) or (a[i,l]=6) then write('|_ ');
                if a[i,l]=0 then write('| |');
                end;
    if (j=2) and (i=4) then writeln;
    if j=3 then begin
                if (a[i,l]=1) or (a[i,l]=4) or (a[i,l]=7) then write('  |');
                if a[i,l]=2 then write('|_ ');
                if (a[i,l]=3) or (a[i,l]=5) or (a[i,l]=9) then write(' _|');
                if (a[i,l]=6) or (a[i,l]=8) or (a[i,l]=0) then write('|_|');
                end;
    if (j=3) and (i=4) then writeln;
    end;
    end;
    end.
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    	private String[][] table;
    	
    	public static void main(String[] args) {
    		String[][] table = {
    				{" _ ", 
    				 "| |",
    				 "|_|"},
    				{"   ", 
    				 "  |",
    				 "  |"},
    				{" _ ", 
    				 " _|",
    				 "|_ "},
    				{" _ ", 
    				 " _|",
    				 " _|"},
    				{"   ", 
    				 "|_|",
    				 "  |"},
    				{" _ ", 
    				 "|_ ",
    				 " _|"},
    				{" _ ", 
    				 "|_ ",
    				 "|_|"},
    				{" _ ", 
    				 "  |",
    				 "  |"},
    				{" _ ", 
    				 "|_|",
    				 "|_|"},
    				{" _ ", 
    				 "|_|",
    				 " _|"}
    		};
    		Scanner in = new Scanner(System.in);
    		while(in.hasNext()){
    			String[] ss = in.nextLine().split(" ");
    			StringBuffer sb = new StringBuffer();
    			for(int i=0;i<ss.length;i++){
    				sb.append(table[Integer.parseInt(ss[i])][0]);
    			}
    			System.out.println(sb);
    			sb = new StringBuffer();
    			for(int i=0;i<ss.length;i++){
    				sb.append(table[Integer.parseInt(ss[i])][1]);
    			}
    			System.out.println(sb);
    			sb = new StringBuffer();
    			for(int i=0;i<ss.length;i++){
    				sb.append(table[Integer.parseInt(ss[i])][2]);
    			}
    			System.out.println(sb);
    			
    		}
    	}
    
    }
    
    

    Python :

    from sys import stdin
    a={"0":" _ ","1":"   ","2":" _ ","3":" _ ","4":"   ","5":" _ ","6":" _ ","7":" _ ","8":" _ ","9":" _ "}
    b={"0":"| |","1":"  |","2":" _|","3":" _|","4":"|_|","5":"|_ ","6":"|_ ","7":"  |","8":"|_|","9":"|_|"}
    c={"0":"|_|","1":"  |","2":"|_ ","3":" _|","4":"  |","5":" _|","6":"|_|","7":"  |","8":"|_|","9":" _|"}
    for d in stdin:
        e=d.split()
        print a[e[0]]+a[e[1]]+a[e[2]]+a[e[3]]
        print b[e[0]]+b[e[1]]+b[e[2]]+b[e[3]]
        print c[e[0]]+c[e[1]]+c[e[2]]+c[e[3]]
    
    • 1

    信息

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