Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int tamanhoarray,casos;
- scanf("%d", &casos);
- while(casos !=0){
- int contde1=0,aux=0;
- scanf("%d", &tamanhoarray);
- int array[tamanhoarray],numeros;
- for(int cont=0; cont<tamanhoarray; cont++){
- scanf("%d", &numeros);
- if(numeros == 1){
- contde1++;
- array[cont] = numeros;
- } else {
- array[cont] = numeros;
- aux++;
- }
- }
- size_t size = sizeof(array) / sizeof(array[0]);
- sort(array, array + size);
- for(int cont=0; cont<=contde1; cont++){
- printf("1 ";)
- }
- for(int cont=0; cont<=tamanhoarray-1; cont++){
- if(array[cont] == 3 && array[cont+1]== 2 && array[cont] != tamanhoarray-1){
- array[cont] = 2;
- array[cont+1] = 3;
- }
- }
- for(int cont=aux; cont>=tamanhoarray-1; cont++){
- printf("%d ",array[cont]);
- }
- cout<<endl;
- casos--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement