您的位置:首页 > 其它

杭电acm--1040

2015-10-13 19:38 369 查看
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.

[align=left]Output[/align]
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.141592653

using 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");
}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: