当前位置:网站首页>Explicit random number
Explicit random number
2022-07-04 19:36:00 【Acacia moon tower】
I want to invite some students to do a questionnaire survey at school , For the objectivity of the experiment , He first generated... By computer N individual 1 To 1000 Random integer between (N≤100), For the repeated numbers , Keep only one , Take out the rest of the same number , Different numbers correspond to different student numbers . And then sort the numbers from small to large , According to the order of arrangement to find students to do research . Please help Mingming finish “ duplicate removal ” And “ Sort ” The job of .
Input yes 2 That's ok The first 1 Behavior 1 A positive integer , Represents the number of generated random numbers :N The first 2 Yes N Positive integers separated by spaces , For the resulting random number .
The output is 2 That's ok , The first 1 Behavior 1 A positive integer M, The number of different random numbers . The first 2 Behavior M Positive integers separated by spaces , Different random numbers in order from small to large .
Input 10 |
Output 8 |
#include <cstdio>
#include <set>
#include <iostream>
using namespace std;
int main() {
set<int> s;
int n, x;
scanf("%d", &n);
while(n--) {
scanf("%d", &x);
s.insert(x);
}
printf("%d\n", s.size());
set<int>::iterator it = s.begin();
while(it != s.end()) {
printf("%d ", *it);
it++;
}
return 0;
}
边栏推荐
- Don't just learn Oracle and MySQL!
- MySQL数据库基本操作-DDL | 黑马程序员
- Hough transform Hough transform principle
- 基于NCF的多模块协同实例
- 联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点
- 牛客小白月赛7 E Applese的超能力
- Detailed explanation of the binary processing function threshold() of opencv
- 整理混乱的头文件,我用include what you use
- 明明的随机数
- "Only one trip", active recommendation and exploration of community installation and maintenance tasks
猜你喜欢
redis分布式锁的8大坑总结梳理

"Only one trip", active recommendation and exploration of community installation and maintenance tasks
关于判断点是否位于轮廓内的一点思考

大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行

The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology

更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?

Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading

【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案

使用canal配合rocketmq监听mysql的binlog日志

Stream流
随机推荐
In flinksql, in addition to data statistics, is the saved data itself a state
Functional interface
26. 删除有序数组中的重复项 C#解答
node_ Exporter deployment
偏移量函数及开窗函数
Online text line fixed length fill tool
Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
1006 Sign In and Sign Out(25 分)(PAT甲级)
Introduction to polyfit software
1672. Total assets of the richest customers
Oracle with as ORA-00903: invalid table name 多表报错
SSL证书续费相关问题详解
An example of multi module collaboration based on NCF
双冒号作用运算符以及命名空间详解
Unity editor extends C to traverse all pictures in folders and subdirectories
How to use async Awati asynchronous task processing instead of backgroundworker?
2021 合肥市信息学竞赛小学组
基于NCF的多模块协同实例
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
@transactional滥用导致数据源连接池耗尽问题