当前位置:网站首页>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;
}
边栏推荐
- 2021 合肥市信息学竞赛小学组
- Shell programming core technology II
- Use canal and rocketmq to listen to MySQL binlog logs
- PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
- 1003 Emergency(25 分)(PAT甲级)
- 92.(cesium篇)cesium楼栋分层
- Unity adds a function case similar to editor extension to its script, the use of ContextMenu
- Go微服务(二)——Protobuf详细入门
- 函数式接口
- Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
猜你喜欢
The 300th weekly match of leetcode (20220703)
C# 使用StopWatch测量程序运行时间
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
English语法_名词 - 使用
PolyFit软件介绍
从实时应用角度谈通信总线仲裁机制和网络流控
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology
FPGA timing constraint sharing 01_ Brief description of the four steps
Pytorch学习(四)
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
随机推荐
FPGA timing constraint sharing 01_ Brief description of the four steps
Shell programming core technology "four"
Detailed explanation of the binary processing function threshold() of opencv
Pointnet/Pointnet++点云数据集处理并训练
Lm10 cosine wave homeopathic grid strategy
Nebula importer data import practice
请教一下 flinksql中 除了数据统计结果是状态被保存 数据本身也是状态吗
偏移量函数及开窗函数
Unity editor extends C to traverse all pictures in folders and subdirectories
1672. 最富有客户的资产总量
OpenCV的二值化处理函数threshold()详解
反射(一)
Oracle with as ora-00903: invalid table name multi report error
Oracle with as ORA-00903: invalid table name 多表报错
SSL证书续费相关问题详解
生成XML元素
Shell 编程核心技术《四》
876. Intermediate node of linked list
勾股数规律(任意三个数能够满足勾股定理需要满足的条件)
Qt实现界面滑动切换效果