http://noi.openjudge.cn/ch0111/08/
""" 1.11 编程基础之二分查找 08 不重复地输出数 http://noi.openjudge.cn/ch0111/08/ Python字符串去重 https://www.jianshu.com/p/b9162f389b5c https://www.cnblogs.com/zhenghiber/p/15110871.html Python:对输入的单词进行字典序排序输出 https://www.cnblogs.com/JodieRao/p/12635910.html Python 程序按字母顺序对单词进行排序 https://www.nhooo.com/python/python-examples-alphabetical-order.html """ n=int(input()) a=list(map(int,input().split())) a.sort() b=[] for word in a: if not word in b: b.append(word) for i in b: print(i,end=' ')
C++代码
/* 1245:不重复地输出数 http://ybt.ssoier.cn:8088/problem_show.php?pid=1245 1.11编程基础之二分查找_08不重复地输出数 http://noi.openjudge.cn/ch0111/08/ */ #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<string> #define INF 999999999 #define N 1000001 #define MOD 1000000007 #define E 1e-3 using namespace std; int a[N]; int main( void ) { int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+1+n); cout<<a[1]; for(int i=2;i<=n;i++) if(a[i]!=a[i-1]) cout<<" "<<a[i]; cout<<endl; return 0; }