1 条题解
-
0
C++ :
#include <cstdlib> #include <cstdio> #include <algorithm> int array[103]; int out[103]; using namespace std; int main() { int n; scanf("%d",&n); int n_n=n; for(int i=1;i<=n;i++) { scanf("%d",&array[i]); } for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(array[i]==array[j]&&i!=j) { n_n--; array[i]=-1; } } } printf("%d\n",n_n); int c=1; for(int i=1;i<=n;i++) { if(array[i]!=-1) { out[c]=array[i]; c++; } } sort(out+1,out+n_n+1); for(int i=1;i<=n_n;i++) { printf("%d ",out[i]); } //system("pause"); return 0; }Pascal :
var n,i,s,x,max:integer; a:array[1..1000] of integer; begin readln(n); max:=0; for i:=1 to n do begin read(x); inc(a[x]); if x>max then max:=x; end; for i:=1 to max do if a[i]<>0 then inc(s); writeln(s); for i:=1 to max do if a[i]<>0 then write(i,' '); end.
- 1
信息
- ID
- 2642
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者