- 明明的随机数
- 2016-03-31 13:34:51 @
评测结果
编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #1: WrongAnswer, time = 0 ms, mem = 552 KiB, score = 0
测试数据 #2: WrongAnswer, time = 0 ms, mem = 556 KiB, score = 0
测试数据 #3: WrongAnswer, time = 0 ms, mem = 556 KiB, score = 0
测试数据 #4: WrongAnswer, time = 0 ms, mem = 552 KiB, score = 0
测试数据 #5: WrongAnswer, time = 0 ms, mem = 556 KiB, score = 0
测试数据 #6: WrongAnswer, time = 0 ms, mem = 552 KiB, score = 0
测试数据 #7: WrongAnswer, time = 15 ms, mem = 556 KiB, score = 0
测试数据 #8: WrongAnswer, time = 0 ms, mem = 552 KiB, score = 0
测试数据 #9: WrongAnswer, time = 0 ms, mem = 556 KiB, score = 0
WrongAnswer, time = 15 ms, mem = 556 KiB, score = 10
代码
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
int a[101],n,i,j;
memset(a,0,sizeof(a));
cin>>n;
int count=n;
for(i=1;i<=n;i++)
cin>>a[i];
sort(a,a+n+1);
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
if(a[i]==a[j])
{
a[j]=0;
count--;
}
cout<<count<<endl;
for(i=1;i<=n;i++)
if(a[i]!=0)cout<<a[i]<<' ';
//system("pause");
return 0;
}
2 条评论
-
pascalzzk LV 8 @ 2016-11-06 10:08:50
不用那么麻烦
···c++
include <cstdio> include <cstring>
using namespace std;
int a[1000];
int main()
{
int n=0,i=0,x=0,l=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&x);
a[x]=1;
}
for(i=1;i<=1000;i++)l+=a[i];
printf("%d\n",l);
for(i=1;i<=1000;i++)
if(a[i]!=0)printf("%d ",i);
return 0;
}
··· -
2016-11-06 10:08:18@
不用那么麻烦
、、、c++
#include <cstdio>
#include <cstring>
using namespace std;
int a[1000];
int main()
{
int n=0,i=0,x=0,l=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&x);
a[x]=1;
}
for(i=1;i<=1000;i++)l+=a[i];
printf("%d\n",l);
for(i=1;i<=1000;i++)
if(a[i]!=0)printf("%d ",i);
return 0;
}
···
- 1