sdf
ádfasfdmhuyy2k3
c_cpp
3 years ago
928 B
4
Indexable
#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<< max << " "; } if(arr[i]<0){ cout << arr[i] << " "; } } // In so duong sau 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 0 cuoi cung 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; } }
Editor is loading...