#include <iostream> using namespace std; int main(void){ int n,j[4]; cin>>n; while(n--){ cin>>j[0]>>j[1]>>j[2]>>j[3]; for(int i=0;i<4;i++){ if(j[i]==0){ int temp=i; while(temp--) j[temp]=j[temp-1]; j[0]=0; } } for(int k=3;k>=0;k--){ if(j[k]==j[k-1]){ int temp=k; j[temp]*=2; while(temp--) j[temp]=j[temp-1]; j[0]=0; } } cout<<j[0]<<" "<<j[1]<<" "<<j[2]<<" "<<j[3]<<endl; } return 0; } |
Double click to view unformatted code.