test 2.1-1
来源:互联网 发布:仙侣奇缘3 数据库密码 编辑:程序博客网 时间:2024/05/02 04:19
我用了vector构造一个可以改变长度的容器line,在编译时用输入题目给的几个数字即可,以非数字作为输入结束。
#include<iostream>
#include<vector>using namespace std;
int main()
{
vector<int> line;
cout << "Enter your unsequenced array :" << endl;
int temp;
while (cin>>temp)
{
line.push_back(temp);
}
int n = line.size();
for (int j = 1; j < n; j++)
{
int key = line[j];
int i = j - 1;
while (i>=0 && line[i] > key) //for test 2.1-2,change this '>' to '<';
{
line[i + 1] = line[i];
i--;
}
line[i+1] = key;
}
cout << "Sequence after programed .\n";
for (int i = 0; i < n; i++)
cout << line[i] << ' ';
return 0;
}
0 0
- test 2.1-1
- test.1
- TEST 1#
- Test 1
- Test(1)
- test-1
- test 2.1-3
- test 2.1-4
- test 1t
- JAVA TEST 1
- Dos Console test...........(1)
- Field_II test 1
- .NET Interview Test 1
- TABLE CONTROL TEST-1
- xss test title 1
- html--1-test
- sql test(1)
- unit test pattern--1
- adb无法使用--关掉防火墙
- 如何清晰的描述BUG? BUG的基本属性都有哪些?
- 开发音乐播放器【1】
- 【数据结构】-简单选择排序Java实现
- poj3687
- test 2.1-1
- XCode7 iOS9无法访问网络的问题
- HDU 1158 DP
- 如何跳转到appstore或其他app
- PAT Basic level practice 12
- 设计模式之七外观模式
- 系统架构师-要求
- 论张飞杀猪,关羽卖枣,他们的绝世武功是如何练成的?
- cmake学习笔记(一)