|
发表于 2022-9-4 14:58:41
|
显示全部楼层
- // 有可能导致名字冲突
- // 想一想,C++为什么要引入名字空间呢?
- // using namespace std;
- // 你这一行代码直接禁用了C++的名字空间
- /*
- #include <bits/stdc++.h>
- using namespace std;
- */
- #include <iostream>
- #include <string>
- #include <limits>
- using std::cin, std::cout, std::endl;
- using std::ios;
- using std::string;
- using std::numeric_limits, std::streamsize;
- // 用全局对象?
- // 为什么?
- // 局部对象不够用吗?
- /*
- string temp;
- int n;
- */
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- //cout.tie(nullptr); // 上面一行把cout从cin中解除绑定,那这一行把谁从谁中解除绑定?
- // 把cout从cout中解除绑定?
- string temp;
- int n;
- cin >> n;
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- while(n--) {
- getline(cin, temp);
- cout << temp << endl;
- }
- return 0;
- }
复制代码 |
|