d

d
 avatar
mhuyy2k3
c_cpp
2 years ago
755 B
4
Indexable
Never
#include <iostream>
#define MAX 100

using namespace std;

int main(){
	int n, m, max, nTests;
	
	cin >> nTests;
	
	for(int nTest = 0; nTest < nTests; nTest++){
		cin >> n >> m;
		int arr[n];
	
		for(int i=0; i<n; i++){
			cin>>arr[i];
		}
		// Tim kiem max;
		max = arr[0];
		
		for(int i=0; i<n; i++){
			if(max<arr[i]){
				max=arr[i];
			}
		}
		
		// In so am truoc
		for(int i=0;i<n;i++){
			if(max == arr[i] && arr[i] < 0){
				cout<< m << " ";
			}
			if(arr[i]<0){
				cout << arr[i] << " ";
			}
		}
		// In so lon hon va bang 0 sau
		for(int i=0;i<n;i++){
			if(max == arr[i] && arr[i] >= 0){
				cout<< m << " ";
			}
			if(arr[i] >= 0){
				cout << arr[i] << " ";
			}
		}
		cout << endl;
	}
	
}