博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
As Easy As A+B
阅读量:7152 次
发布时间:2019-06-29

本文共 1185 字,大约阅读时间需要 3 分钟。

Problem Description

These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights. Give you some integers, your task is to sort these number ascending (升序). You should know how easy the problem is now! Good luck!

Input

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.

Sample Input

23 2 1 39 1 4 7 2 5 8 3 6 9

Sample Output

1 2 31 2 3 4 5 6 7 8 9

#include<stdio.h>

int main()
{
 int t,test,i,j,a[1000];
 scanf("%d",&test);
 while(test--)
{
 scanf("%d",&t);
 for(i=0;i<t;i++)
 {
  scanf("%d",&a[i]);
 }
 for(i=0;i<t-1;i++)
 for(j=1;j<t;j++)
  if(a[j]<a[j-1])
  {
   int k=a[j];
   a[j]=a[j-1];
   a[j-1]=k;
  }
for(i=0;i<t-1;i++)
 {
 printf("%d ",a[i]); 
 }
 printf("%d\n",a[t-1]);
}
return 0;
}

转载于:https://www.cnblogs.com/dreamgoing/p/3560334.html

你可能感兴趣的文章
【干货】Windows进程注入之CreateRemoteThread
查看>>
使用diskbenchmark测试硬盘性能
查看>>
这段代码很Pythonic:相见恨晚的itertools库
查看>>
SAP云平台架构概述
查看>>
确切的说spring框架是做什么的?(翻译自stackoverflow的一个回答)
查看>>
c#工程师用Visual Studio开发dapp应用程序
查看>>
javaScript学习之隐式转换
查看>>
Zend 官方框架增加 Swoole 协程支持 !
查看>>
微服务间的通信如何选择
查看>>
使用PHP搭建Web版Docker管理系统实践
查看>>
我是如何获取到前端用户的IP,并根据IP来获取地理定位的
查看>>
Hyperledger Fabric(功能)
查看>>
前端每日实战:90# 视频演示如何用 CSS 和 D3 创作一个无尽的六边形空间
查看>>
jQuery篇(write Less, Do More)
查看>>
cmake 相关
查看>>
仅用四行代码实现RNN文本生成模型
查看>>
Spring Cloud Config & HA
查看>>
记录一下自己的春招,唯品会、360、京东offer已收、腾讯offer_call已达!!!
查看>>
不再依靠巧合编写 Nginx 配置
查看>>
Python 魔法方法
查看>>