时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:4883

解决:1860

题目描述:

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

本来想用桶排做的,提交后发现runtime error,应该是数的范围太宽了。

//Asimple
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <limits.h>
#define INF 0x7fffffff
using namespace std;
const int maxn = ;
typedef long long ll;
int n, num;
int a[maxn]; int main(){
while( ~scanf("%d",&n) ){
memset(a,,sizeof(a));
while( n -- ){
scanf("%d",&num);
a[num] = ;
}
int k = ;
for(int i=; i<maxn; i++){
if( a[i] ){
printf(k==?"%d":" %d",i);
k ++;
}
}
printf("\n");
}
return ;
}

正解,用STL中的set正好。简单,明了!!

//Asimple
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <limits.h>
#define INF 0x7fffffff
using namespace std;
const int maxn = ;
typedef long long ll;
int n, num;
set<int> s; int main(){
while( ~scanf("%d",&n) ){
s.clear();
while( n -- ){
scanf("%d",&num);
s.insert(num);
}
set<int>::iterator it;
for(it=s.begin(); it!=s.end(); it++){
printf(it==s.begin()?"%d":" %d",*it);
}
printf("\n");
}
return ;
}

每日一九度之 题目1041:Simple Sorting的更多相关文章

  1. 九度oj 题目1041:Simple Sorting

    题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill p ...

  2. 每日一九度之 题目1076:N的阶乘

    时间限制:3 秒 内存限制:128 兆 特殊判题:否 提交:7601 解决:2749 题目描述: 输入一个正整数N,输出N的阶乘. 输入: 正整数N(0<=N<=1000) 输出: 输入可 ...

  3. 每日一九度之 题目1043:Day of Week

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7336 解决:2563 题目描述: We now use the Gregorian style of dating in Russia. ...

  4. 每日一九度之 题目1042:Coincidence

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3007 解决:1638 题目描述: Find a longest common subsequence of two strings. 输入 ...

  5. 每日一九度之 题目1040:Prime Number

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...

  6. 每日一九度之 题目1038:Sum of Factorials

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2109 解决:901 题目描述: John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, ...

  7. 每日一九度之 题目1039:Zero-complexity Transposition

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...

  8. 每日一九度之 题目1033:继续xxx定律

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述:     当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...

  9. 每日一九度之 题目1031:xxx定律

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6870 解决:4302 题目描述:     对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...

随机推荐

  1. iOS 隐藏系统的导航,使用自定义的导航

    #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...

  2. Oracle 10G如何从recovery catalog中Unregister目标数据库

    从10g开始,RMAN简化了unregister目标数据库的步骤 方法1: $rman target system/oracle@test catalog rman/rman@catadb rman& ...

  3. oc 关键字

    assign适用于基本数据类型,weak是适用于NSObject对象,并且是一个弱引用. assign其实页可以用来修饰对象,那么为什么不用它呢?因为被assign修饰的对象在释放之后,指针的地址还是 ...

  4. C++Primer 第十章

    //1.标准库算法不仅可以应用于容器,还可以应用于内置数组,指针. //2.大多数算法都定义在头文件algorithm中.标准库还在头文件numeric中定义了一组数值泛型算法. //3.算法本身不会 ...

  5. Python条件循环判断

    1.条件判断语句 Python中条件选择语句的关键字为:if .elif .else这三个.其基本形式如下: 1 2 3 4 5 6 7 8 9 age_of_cc = 27   age = int( ...

  6. C++Builder 解决绘图闪动问题

    使用双缓冲 Form->DoubleBuffered = true; Panel->DoubleBuffered = true;

  7. ofbiz进击 第二节。 control 理解与创建

    首先要说的是,学习ofbiz,要去http://ofbiz.apache.org/官网里面,去看右边菜单里   Management Apps  的例子,然后找到类似的页面,去看调用的源码方法. co ...

  8. C++之路进阶——codevs1204(寻找子串位置)

    1204 寻找子串位置  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 青铜 Bronze     题目描述 Description 给出字符串a和字符串b,保证b是a的一个子 ...

  9. fread与fwrite的自我理解

    size_t  fread(void* buff,size_t size,size_t count,FILE* stream) 参数1:读取到该buff所指向的内存空间中 参数2:每次读取的字节数,单 ...

  10. paper 36 :[教程] 基于GridSearch的svm参数寻优

    尊重原创~~~ 转载出处:http://www.matlabsky.com/thread-12411-1-1.html 交叉验证(Cross Validation)方法思想简介http://www.m ...