杭电acm--1040

来源:互联网 发布:网络媒介推广 编辑:程序博客网 时间:2024/05/17 04:24

Input contains multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains an integer N (1<=N<=1000 the number of integers to be sorted) and then N integers follow in the same line.
It is guarantied that all integers are in the range of 32-int.
 
Output
For each case, print the sorting result, and one line one case.


#include<stdio.h>#include<stdlib.h>#include<iostream>#include<cmath>#include<iomanip>//#define P 3.141592653using namespace std;void main(){int n, T, t;int arr[1000];cin >> T;while (T--){cin >> n;for (int i = 0; i<n; i++)cin >> arr[i];for (int i = 0; i<n; i++){for (int j = i + 1; j<n; j++){if (arr[i]>arr[j]){t = arr[i];arr[i] = arr[j];arr[j] = t;}}}cout << arr[0];for (int i = 1; i<n; i++)cout << " " << arr[i];cout << endl;}system("pause");}


0 0
原创粉丝点击