解题思路:
注意事项:
参考代码:
#include <iostream> #include <cstring> #include <algorithm> #include <set> using namespace std; int main(){ string s[105]; set<string> ss;//利用set集合去重 int n=0; while(cin>>s[n]){ n++; } sort(s,s+n);//利用sort排序 for(int i=0;i<n;i++){ ss.insert(s[i]); } for(set<string>::iterator it=ss.begin();it!=ss.end();it++){//迭代器,遍历集合中的元素 cout<<*it<<endl; } return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:965 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1195 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:648 |
1157题解浏览:715 |
K-进制数 (C语言描述,蓝桥杯)浏览:925 |
小O的数字 (C++代码)浏览:763 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:420 |
字符串对比 (C++代码)浏览:563 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:576 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:431 |