Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--)
- {
- int n;
- cin>>n; long a[n];
- cin>>a[0];
- long first=a[0],second=a[0];
- for(int i=1;i<n;i++)
- {
- cin>>a[i];
- if(a[i]==first)
- second=a[i];
- else if (a[i] > first)
- {
- second = first;
- first = a[i];
- }
- else if (a[i] > second && a[i] != first)
- second = a[i];
- }
- for(int i=0;i<n;i++)
- {
- if(a[i]!=first)
- {
- cout<<a[i]-first<<" ";
- }
- else
- {
- cout<<a[i]-second<<" ";
- }
- }
- cout<<""<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement