当前位置:网站首页>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;
}
边栏推荐
- 1672. 最富有客户的资产总量
- sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
- Summary and sorting of 8 pits of redis distributed lock
- PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
- OpenCV的二值化处理函数threshold()详解
- Allure of pytest visual test report
- 牛客小白月赛7 E Applese的超能力
- Leetcode fizzbuzz C # answer
- 函数式接口
- 如何使用Async-Awati异步任务处理代替BackgroundWorker?
猜你喜欢
PolyFit软件介绍
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
Bi skills - permission axis
SSRS筛选器的IN运算(即包含于)用法
线上数据库迁移的几种方法
C# 使用StopWatch测量程序运行时间
The 300th weekly match of leetcode (20220703)
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
Online sql to excel (xls/xlsx) tool
Some thoughts on whether the judgment point is located in the contour
随机推荐
An example of multi module collaboration based on NCF
Shell 编程核心技术《四》
redis分布式锁的8大坑总结梳理
PolyFit软件介绍
The page element is vertically and horizontally centered, realizing the vertical and horizontal centering of known or unknown width.
C# 使用StopWatch测量程序运行时间
Go microservice (II) - detailed introduction to protobuf
"Only one trip", active recommendation and exploration of community installation and maintenance tasks
读写关闭的channel是啥后果?
Shell programming core technology "four"
Generate XML elements
2019年蜀山区第十五届青少年信息学竞赛
1672. Total assets of the richest customers
页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
长城证券开户安全吗 买股票怎么开户
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
Technologie de base de la programmation Shell IV
SSRS筛选器的IN运算(即包含于)用法
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用