九度OJ题目1041:Simple Sorting
2015-02-24 23:40
316 查看
题目1041:Simple Sorting
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:4072
解决:1520
题目描述:
You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.
输入:
For each case, the first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next N lines contain N integer numbers(one number per each line) of the original array.
输出:
For each case ,outtput file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.
样例输入:
样例输出:
来源:2008年上海交通大学计算机研究生机试真题
答疑:
解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7765-1-1.html
这个题也是排序而已,不同之处在于,要求我们剔除重复元素,我们未必真的剔除,只需在输出中体现就行,测试样例,输出为王!!!!!
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:4072
解决:1520
题目描述:
You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.
输入:
For each case, the first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next N lines contain N integer numbers(one number per each line) of the original array.
输出:
For each case ,outtput file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.
样例输入:
6 8 8 7 3 7 7
样例输出:
3 7 8
来源:2008年上海交通大学计算机研究生机试真题
答疑:
解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7765-1-1.html
这个题也是排序而已,不同之处在于,要求我们剔除重复元素,我们未必真的剔除,只需在输出中体现就行,测试样例,输出为王!!!!!
#include <stdio.h> #include <algorithm> using namespace std; int arr[1010]; int main() { int n,i; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;++i) scanf("%d",&arr[i]); sort(arr,arr+n); int tmp=arr[0]+1; int numN=arr[n-1]; for(i=0;i<n;++i) { if(arr[i]==numN) { printf("%d\n",numN ); break; } if(arr[i]==tmp) continue; else { tmp=arr[i]; printf("%d ",arr[i]); } } } return 0; }
相关文章推荐
- 九度OJ题目1041:Simple Sorting解题报告
- 九度OJ 1041:Simple Sorting(简单排序) (排序)
- 九度OJ 1041:Simple Sorting(简单排序) (排序)
- 九度oj-1041-Simple Sorting
- <九度 OJ>题目1061:成绩排序
- 九度OJ 题目1043:Day of Week
- 【AC】九度OJ题目1153:括号匹配问题
- 九度OJ-题目1167-数组排序-结构体数组排序
- 【剑指Offer面试编程题】题目1354:和为S的连续正数序列--九度OJ
- 【剑指Offer面试编程题】题目1508:把字符串转换成整数--九度OJ
- 九度OJ 题目1120:全排列
- 【九度OJ】题目1199:找位置
- 九度oj 题目1072:有多少不同的面值组合?(set集合)
- <C/C++基础>九度OJ题目1359--1414解题练习(七)
- 九度OJ 题目1130:日志排序
- 【九度OJ】题目1201:二叉排序树 解题报告
- 【九度OJ】题目1026:又一版 A+B 解题报告
- 【九度OJ】题目1194:八进制 解题报告
- 九度 oj 题目1006:ZOJ问题
- 九度OJ 题目1207:质因数的个数