371 条题解

  • 0
    @ 2015-09-04 18:52:16

    挺简单的,好无聊啊,加我QQ吧 1342181798
    有人玩dota么,QQ约我!!!!!
    #include<stdio.h>
    #include<stdlib.h>
    void sort(int array[],int n)
    {
    int i,j,k,t;
    for(i=1;i<n;i++)
    {
    k=i;
    for(j=i+1;j<=n;j++)
    if(array[j]<array[k])
    k=j;
    t=array[k];array[k]=array[i];array[i]=t;
    }
    }
    int main()
    {
    int n;
    int a[110];
    scanf("%d",&n);
    int num=1;
    int b;
    int ok=1;
    for(int i=1;i<=n;i++)
    {
    scanf("%d",&b);
    for(int j=1;j<=num;j++)
    if(b==a[j])
    ok=0;
    if(ok)
    {
    a[num]=b;
    //printf("%d ",a[num]);
    num++;
    }
    ok=1;
    }
    sort(a,num-1);
    printf("%d\n",num-1);
    for(int i=1;i<num;i++)
    printf("%d ",a[i]);
    //system("pause");
    return 0;
    }

  • 0
    @ 2015-08-31 13:51:25

    秒杀
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    using namespace std;

    int main()
    {
    int N;scanf("%d",&N);
    vector<int> data;
    for(int i=1;i<=N;i++) {
    int x;scanf("%d",&x);
    data.push_back(x);
    }

    sort(data.begin(),data.end());
    int size=unique(data.begin(),data.end())-data.begin();
    printf("%d\n",size);
    for(int i=0;i<size;i++) printf("%d ",data[i]);
    return 0;
    }

  • 0
    @ 2015-08-17 17:31:31

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    int i,j,n,a[101],b[1001]={0},k=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
    cin>>a[i];
    }
    for(i=1;i<=n;i++){
    for(j=1;j<=1000;j++){
    if(j==a[i]){
    if(b[j]==1){
    break;
    }
    b[j]++;
    k++;
    }
    }
    }
    cout<<k<<endl;
    for(j=1;j<=1000;j++){
    if(b[j]==1){
    cout<<j<<' ';
    b[j]--;
    }
    }
    return 0;
    }

  • 0
    @ 2015-08-10 15:57:18

    program exam;
    var i,j,m,n,k,l:longint;
    a,b:array[0..10000] of longint;
    procedure qt(l,r:longint);
    var i,j,m,p:longint;
    begin
    i:=l; j:=r;
    m:=a[(l+r) div 2];
    repeat
    while a[i]<m do inc(i);
    while a[j]>m do dec(j);
    if i<=j then
    begin
    p:=a[i]; a[i]:=a[j]; a[j]:=p;
    inc(i); dec(j);
    end;
    until i>j;
    if i<r then qt(i,r);
    if l<j then qt(l,j);
    end;

    begin
    readln(n);
    for i:=1 to n do
    read(a[i]);
    qt(1,n);
    b[1]:=a[1];
    k:=1;
    for i:=2 to n do
    if a[i]<>b[k] then
    begin
    inc(k);
    b[k]:=a[i];
    end;
    writeln(k);
    for i:=1 to k do
    write(b[i],' ');
    end.

  • 0
    @ 2015-08-09 21:56:07

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<vector>
    using namespace std;

    int a[101];
    vector<int> v;

    int main()
    {
    int n, bri, ans=0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    scanf("%d", &a[i]);

    sort(&a[1], &a[1]+n);
    for(int i=1; i<=n; i++){
    if(bri != a[i]){
    ans++;
    v.push_back(a[i]);
    }
    bri = a[i];
    }
    printf("%d\n", ans);
    for(int i=0; i<v.size(); i++)
    printf("%d ", v[i]);
    return 0;
    }
    水一发~~~(0,0)

  • 0
    @ 2015-08-04 14:34:01

    桶排最合适,各种排序都可以

  • 0
    @ 2015-07-23 17:17:47

    桶排
    var
    n,i,x,s:longint;
    a:array[0..1000]of longint;
    begin
    read(n);
    for i:=1 to n do
    begin
    read(x);
    a[x]:=1;
    end;
    for i:=1 to 1000 do
    if a[i]=1 then s:=s+1;
    writeln(s);
    for i:=1 to 1000 do
    if a[i]=1 then write(i,' ');
    end.

  • 0
    @ 2015-07-16 10:14:16

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main()
    {
    int n,m,k,j,i;int a[101];bool b[1001]={0};
    m=0;cin>>n;
    for(int i=1;i<=n;++i)
    {
    cin>>a[i];
    ++b[a[i]];
    }
    for(j=0;j<=1000;++j)
    if(b[j]!=0)
    ++m;
    cout<<m<<endl;
    for(j=0;j<=1000;++j)
    if(b[j]!=0)

    cout<<j<<" ";
    return 0;

    }

  • 0
    @ 2015-07-16 09:56:41

    #include<iostream>
    using namespace std;
    int main ()
    {
    int n;
    int s=0,t=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    a[i]=0;
    for(int i=0;i<n;++i)
    cin>>a[i];
    for(int j=0;j<n;++j)
    for(int k=0;k<n-j;++k)
    if(a[k]>a[k+1])
    {
    t=a[k];a[k]=a[k+1];a[k+1]=t;
    }
    for (int i=0; i<n; ++i)
    if(a[i]==a[i+1])
    {
    a[i]=false;
    }
    for (int i=0; i<n; ++i)
    if (a[i]!=false)
    {
    ++s;
    }
    cout<<s<<endl;
    for (int i=0;i<n;++i)
    if (a[i]!=false)
    cout<<a[i]<<" ";
    return 0;
    }
    为什么50?

  • 0
    @ 2015-07-16 09:53:18

    #include<iostream>
    using namespace std;
    int main()
    {
    int n,i;
    set<int>x;
    while(n--){
    scanf("%d",&i);
    x.insert(i);
    }
    {
    printf("%d\n",x.size());
    while(x.size())
    printf("%d",*(x.begin()));
    x.erase(x.begin());
    putchar(x.size()?' ':'\n');

    }
    return 0;

    }

  • 0
    @ 2015-07-16 09:51:20

    #include<cstdio>
    #include<iostream>
    using namespace std;
    int main ()
    {
    int n,m,t;cin>>n;t=0;
    int a[101];bool b[1001]={0};
    for(int i=0;i<n;++i)
    {
    cin>>a[i];
    ++b[a[i]];
    }
    for(int j=0;j<1001;++j)
    if(b[j]!=0)
    {
    ++t;
    }
    cout<<t<<endl;

    for(int j=0;j<1001;++j)
    if(b[j]!=0)

    cout<<j<<" ";

    }

  • 0
    @ 2015-06-11 22:43:40

    program Notes;
    var a:array[1..1000]of boolean;
    var max,i,n,t,temp,ans:integer;
    begin
    fillchar(a,sizeof(a),false);
    readln(n);
    ans:=n;
    max:=0;
    for i:=1 to n do
    begin
    read(t);
    if t>max then max:=t;
    if a[t] then dec(ans);
    a[t]:=true;
    end;
    writeln(ans);
    for i:=1 to max do
    begin
    if (temp=ans-1)and(a[i]) then break;
    if a[i] then
    begin
    write(i,' ');
    temp:=temp+1;
    end;
    end;
    write(i);
    end.

  • 0
    @ 2015-06-03 23:01:13

    #include<cstdio>
    #include<set>
    using namespace std;
    int main(){
    int n,i;
    set<int>x;
    scanf("%d",&n);
    while(n--){
    scanf("%d",&i);
    x.insert(i);
    }
    printf("%d\n",x.size());
    while(x.size()){
    printf("%d",*(x.begin()));
    x.erase(x.begin());
    putchar(x.size()?' ':'\n');
    }
    }

    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 460 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    Accepted, time = 0 ms, mem = 468 KiB, score = 100

  • 0
    @ 2015-05-17 14:57:55

    测试数据 #0: Accepted, time = 0 ms, mem = 436 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 436 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 440 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 440 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 436 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 436 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 444 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 440 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 436 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 436 KiB, score = 10
    Accepted, time = 0 ms, mem = 444 KiB, score = 100

  • 0
    @ 2015-05-17 14:57:24

    var
    a:array[1..1000]of boolean;
    n,i,s,m:integer;
    begin
    readln(n);
    for i:=1 to n do begin read(s);if not a[s] then begin a[s]:=true;inc(m);end;end;
    writeln(m);
    for i:=1 to 1000 do if a[i] then write(i,' ');
    end.

  • 0
    @ 2015-05-06 21:10:04

    var i,j,x,n,k:integer;
    a,b:array[1..110] of integer;
    begin
    fillchar(a,sizeof(a),0);
    k:=0;

    readln(n);
    for i:=1 to n do
    read(a[i]);

    for i:=1 to n-1 do
    for j:=i+1 to n do
    begin
    if a[i]=a[j] then
    a[j]:=0
    else if a[i]>a[j] then
    begin
    x:=a[i];
    a[i]:=a[j];
    a[j]:=x;
    end;
    end;

    for i:=1 to n do
    begin
    if a[i]<>0 then
    begin
    b[i]:=a[i];
    k:=k+1;
    end;
    end;

    writeln(k);
    for i:=1 to n do
    begin
    if b[i]<>0 then
    write(b[i],' ');
    end;
    end.

  • 0
    @ 2015-04-15 22:01:40

    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 268 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 268 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 268 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 268 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    Accepted, time = 0 ms, mem = 272 KiB, score = 100
    代码
    #include<cstdio>
    #include<iostream>
    using namespace std;
    int main ()
    {
    int n,a[1000],s=0,i,j,t=0;
    cin>>n;
    for (i=1; i<=n; i++)
    cin>>a[i];
    for (j=1; j<=n-1; j++)
    for (i=1; i<=n-j; i++)
    if (a[i]>a[i+1])
    {t=a[i]; a[i]=a[i+1];a[i+1]=t;}
    for (i=1; i<=n; i++)
    if (a[i]==a[i+1])
    a[i]=0;
    for (i=1; i<=n; i++)
    if (a[i]!=0)
    s=s+1;
    cout<<s<<endl;
    for (i=1; i<n; i++)
    if (a[i]!=0)
    cout<<a[i]<<" ";
    if (a[n] != 0)
    cout << a[n];
    return 0;
    }

  • 0
    @ 2015-04-15 22:01:03

    #include<cstdio>
    #include<iostream>
    using namespace std;
    int main ()
    {
    int n,a[1000],s=0,i,j,t=0;
    cin>>n;
    for (i=1; i<=n; i++)
    cin>>a[i];
    for (j=1; j<=n-1; j++)
    for (i=1; i<=n-j; i++)
    if (a[i]>a[i+1])
    {t=a[i]; a[i]=a[i+1];a[i+1]=t;}
    for (i=1; i<=n; i++)
    if (a[i]==a[i+1])
    a[i]=0;
    for (i=1; i<=n; i++)
    if (a[i]!=0)
    s=s+1;
    cout<<s<<endl;
    for (i=1; i<n; i++)
    if (a[i]!=0)
    cout<<a[i]<<" ";
    if (a[n] != 0)
    cout << a[n];
    return 0;
    }

  • 0
    @ 2015-02-07 08:51:36

    var
    a:array[1..1000] of longint;
    i,j,k,n,s:longint;
    begin
    readln(n);
    for i:=1 to n do read(a[i]);
    for i:=1 to n-1 do
    for j:=i+1 to n do
    begin
    if a[i]>a[j] then
    begin
    k:=a[i];
    a[i]:=a[j];
    a[j]:=k;
    end;
    if a[i]=a[j] then
    begin
    a[i]:=0;
    inc(s);
    end;
    end;
    writeln(n-s);
    for i:=1 to n do
    if a[i]<>0 then
    write(a[i],' ');
    writeln;
    end.

  • 0
    @ 2015-02-03 09:08:02

    #include <cstdio>

    using namespace std;

    int a[101];

    void quick_sort(int *s, int n)
    {
    int i = 0, j = n-1, mid = s[n/2];
    while (i <= j){
    while (i < n && s[i] < mid) i ++;
    while (j > 0 && s[j] > mid) j --;
    if (i <= j){
    int t = s[i];
    s[i] = s[j];
    s[j] = t;
    i ++; j --;
    }
    }
    if (i < n-1) quick_sort(s + i, n - i);
    if (j > 0) quick_sort(s, j + 1);
    }

    int main()
    {
    //init
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
    scanf("%d", &a[i]);

    //sort
    quick_sort(a, n);

    //output
    int m = 0;
    for (int i = 0; i < n; i ++)
    if (i == 0 || a[i] != a[i-1])
    m ++;
    printf("%d\n", m);
    for (int i = 0; i < n; i ++)
    if (i == 0 || a[i] != a[i-1])
    printf("%d ", a[i]);
    printf("\n");

    return 0;
    }

信息

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