notitle

nodes
 avatar
mhuyy2k3
c_cpp
a year ago
648 B
3
Indexable
Never
#include <iostream>

using namespace std;

int main(){
	int n, m, i, j, tmp, max, n_tests, n_test;
	
	// n test
	
	cin >> n_tests;
	
	for(n_test = 0; n_test < n_tests; n_test++){
		// C in
		cin >> n;
		cin >> m;
		int arr[n];
		for(i = 0; i<n; i++){
			cin >> arr[i];
		}
		// Sort
		for(i = 0; i<n-1; i++){
			for(j = i; j < n; j++){
				if(arr[i]>arr[j]){
					tmp = arr[i];
					arr[i] = arr[j];
					arr[j] = tmp;
				}
			}
		}
		
		// Find max
		max = arr[n-1];
		
		// C out
		for(i = 0; i<n; i++){
			if(arr[i] == max){
				cout << m << " ";
			}
			cout << arr[i] << " ";
		}
		cout << endl;
	}
}