- 明明的随机数
- 2017-02-12 17:15:53 @
#include<stdio.h>
int main()
{
int a[1001],i,n,tong,b=0;
for(i=1;i<=1000;i++)
{
a[i]=0;
}
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&tong);
if(a[tong]!=1)
{
a[tong]=1;
b++;
}
}
printf("%d\n",b);
for(i=1;i<=1000;i++)
{
if(a[i]==1)
printf("%d ",i);
}
}
1 条评论
-
wuyu2004 LV 6 @ 2017-06-28 10:29:33
pascal
var i,j,k,n,l,t:longint;
a:array[1..10000] of longint;
begin
read(n);
k:=n;
for i:=1 to k do
begin
read(l);
a[l]:=a[l]+1;
if a[l]>1 then
begin
a[l]:=1;
n:=n-1;
end;
end;
writeln(n);
for i:=1 to 1000 do
begin
if a[i]=1 then inc(t);
if t=n then
begin
writeln(i);
break;
end;
if a[i]=1 then write(i,' ');
end;
end.
- 1