九度oj 1041
来源:互联网 发布:mac itunes 怎么登陆 编辑:程序博客网 时间:2024/05/16 14:00
- 题目描述:
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.
- 样例输入:
68 8 7 3 7 7
- 样例输出:
3 7 8
- 来源:
2008年上海交通大学计算机研究生机试真题
#include<iostream>#include<algorithm>#include<stdlib.h>using namespace std;int main(){ int n; int a[1001]; int b[1001]; while(cin>>n) { for(int y=0;y<n;y++) { cin>>b[y]; } a[0]=b[0]; int cnt=0,i=1; for(int q=1;q<n;q++) { int s=b[q]; int flag=0; for(int j=0;j<i;j++) { if(s==a[j]) { flag=1; break; } } if(flag==0) { a[i++]=s; continue; } if(flag==1) { continue; } } sort(a,a+i); for(int p=0;p<=i-2;p++) { cout<<a[p]<<" "; } cout<<a[i-1]<<endl; } }
0 0
- 九度OJ---1041
- 九度oj 1041
- 【九度OJ】1041【排序】
- 【九度OJ】:九度OJ 1050
- 【九度OJ】:九度OJ 1053
- 【九度OJ】:九度OJ 1056
- 【九度OJ】:九度OJ 1059
- 【九度OJ】:九度OJ 1206
- 九度OJ 题目1041:Simple Sorting
- 九度OJ题目1041:Simple Sorting
- 九度oj-1041-Simple Sorting
- 九度OJ 1041 简单排序
- 九度OJ:1000
- 【九度OJ】 1006
- 九度 OJ 1499
- 九度OJ-1002
- 九度OJ-1003
- 九度OJ 1004
- C++中public,protected,private访问小结
- 欢迎使用CSDN-markdown编辑器
- String和StringBuffer的equals方法比较
- 系统函数C字符串的实现(7):wcsrev
- 路由器的原理及其配置(二)
- 九度oj 1041
- zoj 3201 Tree of Tree 树形dp基础题——树形背包
- 创业之前你需要了解的九个真相
- 黑马程序员------OC中计算NSString 字符串的长度
- Java NIO系列教程(一) Java NIO 概述
- ORACLE 第4节 多表查询
- 基于Qt的连连看小游戏
- NZND-第四天
- 笨笨熊搬家——交通(java)