讨论 / 明明的随机数【求解 为什么通不过】
左岩 2016-11-10 01:09:07
点我顶贴 收藏 删除
#include <iostream>

using namespace std;

int main()

{

int i;

int a[11];

int l;

int t;

int temp;

cin>>i;

cout<<endl;

for(int j=1;j<=10;j++)

{

cin>>a[j];

}

for(int m=1;m<=10;m++)

{

for(int n=m+1;n<=i;n++)

{//2 3 4 5 6 7 8 9 10

//3 4 5 6 7 8 9 10

//4 5 6 7 8 9 10

if(a[m]==a[n])

{

temp=a[n];

a[n]=a[i];

a[i]=temp;

i=i-1;

}

}

}

cout<<i<<endl;//这个是输出转换完的剩余个数

for(int w=1;w<=i-1;w++)

{

int x=w;

for(int l=w+1;l<=i;l++)

if(a[l]<a[x]) x=l;

t=a[x];a[x]=a[w];a[w]=t;

}

for(int u=1;u<=i;u++)

cout<<a[u]<<" ";

return 0;

}

#1 小小莫@2016-11-12 00:03:43
回复 删除
STL 快速排序加去重,一遍过
#2 Nightingalelyy@2016-11-14 03:05:40
回复 删除
数组开的太小了
查看更多回复
提交回复