当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
FPGA timing constraint sharing 01_ Brief description of the four steps
指定输出的字符集
Specify the character set to output
1672. Total assets of the richest customers
Online text line fixed length fill tool
添加命名空间声明
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
测试工程师如何“攻城”(下)
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
一文掌握数仓中auto analyze的使用
LeetCode第300场周赛(20220703)
mysql中explain语句查询sql是否走索引,extra中的几种类型整理汇总
Shell programming core technology II
Technologie de base de la programmation Shell IV
Reflection (I)
HDU 1372 & POJ 2243 Knight Moves(广度优先搜索)
One question per day (2022-07-02) - Minimum refueling times
PolyFit软件介绍
从实时应用角度谈通信总线仲裁机制和网络流控
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++








