View Code of Problem 10

#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int a[5];
		a[0]=0;
		for(int i=1;i<=4;i++){
			scanf("%d",&a[i]);
		}
		
		for(int i=4;i>=1;i--){
			if(a[i]==a[i-1]){
				a[i]=2*a[i];
				int j=i-1;
				while(j>=1){
					a[j]=a[j-1];
					j--;
				}
			}
			
			
			
		}
	
		for(int i=1;i<=3;i++){
			printf("%d ",a[i]);
		}
		printf("%d\n",a[4]);
		
	} 
	
	
	
	return 0;
} 

Double click to view unformatted code.


Back to problem 10