解题思路:利用了vector作为存储的媒介
注意事项:
参考代码:
#include <iostream> #include <string.h> #include <vector> using namespace std; int main() { int n=0; vector<string> list; string str; cin >> n; while(n > 0) { getline(cin,str); if(str.empty()) continue; list.push_back(str); n--; } for (size_t var = 0; var < list.size(); ++var) { cout << list[var] << endl; cout << endl; } while(cin)//是否结束 { str.clear(); cin >> str; if(str.empty())//读入EOF时会存在最后一次读入为空的情况 continue; cout << str << endl << endl; } return 0; }
0.0分
0 人评分
简单编码 (C++代码)浏览:678 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1195 |
C语言训练-大、小写问题 (C语言代码)浏览:732 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:338 |
wu-淘淘的名单 (C++代码)浏览:1339 |
1113题解浏览:791 |
1017题解浏览:605 |
A+B for Input-Output Practice (V) (C语言代码)浏览:470 |
A+B for Input-Output Practice (VII) (C语言代码)浏览:528 |
sizeof的大作用 (C语言代码)浏览:1028 |