剑指offer上的第14题,九度OJ为了确保输出的结果的唯一性,在输出上做了修改,因此采用的方法自然与书本上不同,这里没有限制,思来想去还是用最简单的方法来做了,非常简单的方法,直接上代码。
题目描述:
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。
输入:
每个输入文件包含一组测试案例。
对于每个测试案例,第一行输入一个n,代表该数组中数字的个数。
接下来的一行输入n个整数。代表...
分类:
其他好文 时间:
2014-05-15 08:14:26
阅读次数:
285
Pat1043代码
题目描述:
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:
The left subtree of a node contains only nodes with keys less than t...
分类:
其他好文 时间:
2014-05-15 05:09:59
阅读次数:
351
Pat1043代码题目描述:A Binary Search Tree (BST) is
recursively defined as a binary tree which has the following properties:The left
subtree of a node contain...
分类:
其他好文 时间:
2014-05-14 22:03:25
阅读次数:
487
Pat1018代码
题目描述:
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to an...
分类:
其他好文 时间:
2014-05-13 23:27:04
阅读次数:
582
Pat1044代码
题目描述:
Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can...
分类:
其他好文 时间:
2014-05-13 14:33:08
阅读次数:
437
Pat1016代码
题目描述:
A long-distance telephone company charges its customers by the following rules:
Making a long-distance call costs a certain amount per minute, depending on the time of day w...
分类:
其他好文 时间:
2014-05-13 06:45:05
阅读次数:
460
Pat1076代码
题目描述:
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with foll...
分类:
其他好文 时间:
2014-05-10 04:50:24
阅读次数:
403
Pat1060代码
题目描述:
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*105 with simple chopping. Now given...
分类:
其他好文 时间:
2014-05-08 02:07:49
阅读次数:
452
Pat1063代码
题目描述:
Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets,
and Nt is the to...
分类:
其他好文 时间:
2014-04-29 13:44:20
阅读次数:
325