372 条题解

  • -1
    @ 2016-10-02 10:08:29

    set 轻松AC
    ```c++
    #include<iostream>
    #include<set>
    using namespace std;
    int main(){
    int n;
    cin>>n;
    set<int> b;
    for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    b.insert(x);
    }
    cout<<b.size()<<endl;
    int j=b.size();
    for(int i=1;i<=j;i++){
    int x=*b.begin();
    cout<<x<<' ';
    b.erase(*b.begin());
    }

    }
    ```

  • -1
    @ 2016-09-16 18:51:38

    program p1316;
    var a:array[1..1000] of boolean;s:array[1..100] of longint;
    i,n:longint;
    begin
    readln(n);fillchar(a,sizeof(a),false);
    for i:=1 to n do
    begin
    read(s[i]);
    a[s[i]]:=true;
    end;
    writeln(n);
    for i:=1 to 1000 do
    begin
    if a[i] then write(i);
    end;
    end.

  • -1
    @ 2016-08-17 15:38:15

    #include<math.h>
    using namespace std;
    int a[1000];
    int main()
    {
    int i,j,k,n,t=0;
    cin>>n;
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    for(j=i+1;j<n;j++)
    if(a[i]==a[j])
    a[j]=0;

    for(i=0;i<n;i++)
    for(j=i+1;j<n;j++)
    if(a[i]>a[j])
    swap(a[i],a[j]);
    for(i=0;i<n;i++)
    if(a[i]!=0)
    t++;
    cout<<t<<endl;
    for(i=0;i<n;i++)
    if(a[i]!=0)
    cout<<a[i]<<" ";
    return 0;
    }

  • -1
    @ 2016-08-14 21:01:01
    #include <set>
    #include <cstdio>
    using namespace std;
    int n,tmp;
    set<int> S;
    set<int>::iterator it;
    int main(){
        scanf("%d",&n);
        for (int i=1;i<=n;i++){
            scanf("%d",&tmp);
            S.insert(tmp);
        }
        printf("%d\n",S.size());
        for (it=S.begin();it!=S.end();it++) printf("%d ",*it);
    }
    

    花式AC之set

  • -1
    @ 2016-07-17 13:12:05
    include <cstdio> include <cstring> include <algorithm>
    using namespace std;
    int main()
    {
    int n,a[101],c[101],i,j,m=0;
    bool b[1001]={0};
    cin>>n;
    for (i=0;i<n;i++) { cin>>a[i];
    if (b[a[i]]==0)
    {
    c[m]=a[i];
    m++;
    b[a[i]]=1;
    }
    }
    sort(c+0,c+m);
    cout<<m<<endl;
    for (i=0;i<m;i++)
    cout<<c[i]<<" ";
    }```
    水水水淼
    
  • -1
    @ 2016-07-17 13:11:51
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    int main()
    {
        int n,a[101],c[101],i,j,m=0; 
        bool b[1001]={0};
        cin>>n;
        for (i=0;i<n;i++)
        {
            cin>>a[i];
            if (b[a[i]]==0)
            {
                c[m]=a[i];
                m++;
                b[a[i]]=1;
            }
        }
        sort(c+0,c+m);
        cout<<m<<endl; 
        for (i=0;i<m;i++)
        cout<<c[i]<<" ";
    }```
    水水水淼
    
  • -1
    @ 2016-07-12 11:09:07

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    int a[100],m,x,k,j,l=0,t,b=0;
    cin>>m;
    for(int i=1;i<=m;++i)
    cin>>a[i];

    for(int i=1;i<=m-1;i++)
    {
    k=i;
    for(int j=i+1;j<=m;j++)
    if(a[k]>a[j]) k=j;
    if(k!=i)
    {
    t=a[i];
    a[i]=a[k];
    a[k]=t;
    }
    }

    for(int i=1;i<=m-1;i++)
    {
    k=i;
    for(int j=i+1;j<=m;j++)
    if(a[k]==a[j])

    {a[k]=0; b+=1;}

    }
    cout<<m-b<<endl;
    for(int i=1;i<=m;++i)
    {
    if(a[i]!=0)
    cout<<a[i]<<" ";
    }

    }

  • -1
    @ 2016-06-24 13:41:22

    直接用桶排序搞定,sort什么的对于这道题太复杂!
    //超短
    #include<iostream>
    #define f for(int i=1;i<=n;++i)
    using namespace std;
    bool a[1001];
    int s,q,n;
    int main()
    {
    cin>>n;
    f
    {
    cin>>s;
    a[s]=1;
    }
    n=1000;
    f if(a[i]) q++;
    cout<<q<<endl;
    f if(a[i]) cout<<i<<" ";
    cout<<endl;
    }

  • -1
    @ 2014-11-05 13:04:05

    #include<stdio.h>
    int a[100];
    int main()
    {
    int n,i,j,temp;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<=n-1;i++)
    for(j=1;j<=n-i;j++)
    if(a[j]<a[j-1])
    {
    temp=a[j];
    a[j]=a[j-1];
    a[j-1]=temp;
    }
    for(j=1;j<=n;j++)
    printf("%d",a[j]);
    return 0;
    }

  • -2
    @ 2021-07-15 15:39:33
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int main(){
      int n;
      scanf("%d",&n);
      int f=n;
      int a[n];
      for(int i=0;i<n;i++)scanf("%d",a+i);
      for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i!=j && a[i]==a[j] && a[i]!=-1 && a[j]!=-1 )f--,a[j]=-1;
          }
      }
      sort(a,a+n);
      printf("%d\n",f);
      for(int i=0;i<n;i++){
        if(a[i]!=-1)printf("%d ",a[i]);
      }
      return 0;
    }
    
  • -2
    @ 2016-12-13 17:15:47

    秒杀!
    c++
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int main()
    {
    int a[105],n,i,x;
    cin>>n; for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n); x=unique(a,a+n)-a;
    cout<<x<<endl; for(int i=0;i<x;i++) cout<<a[i]<<" ";
    return 0;
    }

  • -2
    @ 2016-05-14 17:18:34

    题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
    题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
    题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
    题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
    题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
    题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
    题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
    题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
    题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
    题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
    题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
    题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
    题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
    题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
    题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
    题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
    题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
    题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
    题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
    题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
    题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
    题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
    题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
    题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
    题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题

信息

ID
1316
难度
3
分类
其他 | 排序 点击显示
标签
递交数
9961
已通过
4874
通过率
49%
被复制
33
上传者