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