1072. 小强的单词本

Fifnmar

快乐水一水,可以直接用set。
上面那个吹python的我觉得你应该先学学Markdown(滑稽)

#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
    int n;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> n;
    cin.get();
    set<string> a;
    string word;
    for (int i = 0; i < n; ++i) {
        cin >> word;
        a.insert(word);
    }
    for (auto const &i : a) {
        cout << i << '\n';
    }
}
Andrew-Malcom

python天下无敌!!!
代码附上:
i=int(input())
message=[]
for x in range(i):
message.append(input())
for line in sorted(set(message)):
print(line)

╮ 潜心 ╰

STL

include

include

using namespace std;
int main() {
set a;
int n;
cin >> n;
while(n–) {string s;cin >> s;a.insert(s);}
for (set::iterator i=a.begin(); i!=a.end(); ++i)
cout << *i << endl;
return 0;
}

C++ set自带排序性质
用一个for循环即可

e_mmmmmm

int main(int argc, const char * argv[]) {
int n;
set s;
string str;
cin>>n;
while(n–){
cin>>str;
s.insert(str);
}
for(auto it=s.begin();it!=s.end();it++)
cout<<*it<<endl;
return 0;
}

你当前正在回复 博客/题目
存在问题!