delete pics to save space
This commit is contained in:
39
history_source/ccf 入门篇/U5/5.3.8.cpp
Normal file
39
history_source/ccf 入门篇/U5/5.3.8.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()//20 40 32 67 40 20 89 300 400 15
|
||||
{
|
||||
int n,m,x;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
int sr[n];
|
||||
for(int i=0;i<n;i++) cin>>sr[i];
|
||||
for(int i=n-1;i>0;i--)
|
||||
{
|
||||
for(int j=0;j<i;j++)
|
||||
{
|
||||
if(sr[j]>sr[j+1]){
|
||||
x=sr[j];
|
||||
sr[j]=sr[j+1];
|
||||
sr[j+1]=x;
|
||||
}
|
||||
}
|
||||
}
|
||||
m=n;
|
||||
x=sr[0];
|
||||
for(int i=1;i<n;i++)
|
||||
{
|
||||
if(x==sr[i]) m--;
|
||||
x=sr[i];
|
||||
}
|
||||
cout<<m<<endl;
|
||||
x=sr[0];
|
||||
cout<<x<<" ";
|
||||
for(int i=1;i<n;i++)
|
||||
{
|
||||
if(x!=sr[i]) cout<<sr[i]<<" ";
|
||||
x=sr[i];
|
||||
}
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user