Quick actions

cmd+k|ctrl+k

Navigation

Languages

단가 수량 순위

Snippet info

Language

Java

Visibility

public

Author

4041itq

Created

2018-04-22T03:58:34Z

Updated

2018-04-22T12:08:49Z

class Main {
    public static void main(String[] args) {
        int a[]=new int[20];
        int b[]=new int[20];
        int c[]=new int[20];
        int s[]=new int[20];
        
        int i;
        
        for(i=0; i<=19; i++){
            a[i]=(int)(Math.random()*10000);
            b[i]=(int)(Math.random()*45);
            c[i]=a[i]*b[i];
        }
        
        for(i=0; i<=19; i++){
            for(int k=i+1; k<=19; k++){
                if(c[i]>c[k]){
                    int temp=c[k];
                    c[k]=c[i];
                    c[i]=temp;
                    
                    temp=a[k];
                    a[k]=a[i];
                    a[i]=temp;
                    
                    temp=b[k];
                    b[k]=b[i];
                    b[i]=temp;
                }
            }
        }
        int n=1;
        for(i=19; i>=0; i--){
            s[i]=n++;
        }
        for(int num=19; num>=0; num--)
            System.out.printf("%d %d %d\n",a[num],b[num],s[num]);
    }
}
INFO