题解 | #Simple Sorting#
Simple Sorting
https://www.nowcoder.com/practice/139761e0b59a405786898b7f2db9423f
#include <iostream> #include<algorithm> using namespace std; int main() { int n=0; cin>>n; int *arr=new int[n]; int index=0; while(index!=n){ int inp=0; cin>>inp; arr[index]=inp; index++; } sort(arr,arr+n); for(int i=0;i<n+1;){ if((arr[i]<arr[i+1])||i==n){ if(i==n){ cout<<arr[n-1]; break; } cout<<arr[i]<<" "; i++; } else { i++; } } }//去重复值的排序