当前位置:网站首页>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;
}
边栏推荐
- Pointnet/Pointnet++点云数据集处理并训练
- 使用canal配合rocketmq监听mysql的binlog日志
- “只跑一趟”,小区装维任务主动推荐探索
- Shell programming core technology "four"
- Explore the contour drawing function drawcontours() of OpenCV in detail with practical examples
- 求2的n次方
- In flinksql, in addition to data statistics, is the saved data itself a state
- Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
- 指定输出的字符集
- Shell programming core technology II
猜你喜欢
关于判断点是否位于轮廓内的一点思考

92.(cesium篇)cesium楼栋分层

欧拉函数

在线文本行固定长度填充工具

用实际例子详细探究OpenCV的轮廓绘制函数drawContours()

勾股数规律(任意三个数能够满足勾股定理需要满足的条件)

YOLOv5s-ShuffleNetV2

2022CoCa: Contrastive Captioners are Image-Text Fountion Models

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

Bi skills - permission axis
随机推荐
1003 Emergency(25 分)(PAT甲级)
LeetCode第300场周赛(20220703)
Wireshark网络抓包
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
牛客小白月赛7 I 新建 Microsoft Office Word 文档
更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
矩阵翻转(数组模拟)
redis分布式锁的8大坑总结梳理
Unity editor extends C to traverse all pictures in folders and subdirectories
长城证券开户安全吗 买股票怎么开户
How test engineers "attack the city" (Part 2)
自由小兵儿
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
QT realizes interface sliding switching effect
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
一文掌握数仓中auto analyze的使用
关于判断点是否位于轮廓内的一点思考
Add namespace declaration
The difference and usage between substr (), slice (), and substring () in the string interception methods of "understand series after reading"
The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology