알고리즘/SW Expert Academy

[D4] 7829. 보물왕 태혁

혬혬 2019. 10. 6. 11:01
728x90
#include <stdio.h>

int main(){
	int test_case=0;
    scanf("%d",&test_case);
    for(int q=0;q<test_case;q++){
   		int amount=0;
        scanf("%d",&amount);
        int i=0;
        int numbers[101]={0};
        for(i;i<amount;i++){
       		scanf("%d",&numbers[i]);
        }
        for(int count=0;count<i;count++){
    		for(int k=0;k<i-1;k++){
   			 if(numbers[k]>numbers[k+1]){
    			int temp=numbers[k];
        		numbers[k]=numbers[k+1];
        		numbers[k+1]=temp;
   			}
            }
        }
        int index=i/2;
        if(i%2==0){
  			printf("#%d %d\n",q+1,numbers[index]*numbers[index-1]);
    	}else{
    	printf("#%d %d\n",q+1,numbers[index]*numbers[index]);
   	 }
    }
return 0;
}
728x90