首页 > 其他 > 详细

P1059 明明的随机数

时间:2019-08-01 20:46:44      阅读:175      评论:0      收藏:0      [点我收藏+]

P1059 明明的随机数

题目链接:https://www.luogu.org/problem/P1059

代码:

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int a[1005]={0};//将1到1005全部标为0;
    int b[1005];
    int n,i,j=0,t;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&t);
        a[t] = 1;//将该数标记为1;
    }
    for(i=0;i<=1000;i++){//搜索被标记为1的所有数;
        if(a[i]==1){
            b[j] = i;//将数存入另一个数组中;
            j++;
        }
    }
    sort(b,b+j);//从小到大排序;
    printf("%d\n",j);
    for(i=0;i<j;i++){
        printf("%d ",b[i]);
    }
    printf("\n");
    return 0;
}

P1059 明明的随机数

原文:https://www.cnblogs.com/zz9100/p/11285168.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!