From 36f6186573b1bb29edbe4d42bfe148a58e434aae Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 25 Jul 2021 19:05:36 +0800 Subject: [PATCH] 1347: Unix-head http://tk.hustoj.com/reinfo.php?sid=1324925 --- tk.hustoj.com/1347/1347.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tk.hustoj.com/1347/1347.cpp diff --git a/tk.hustoj.com/1347/1347.cpp b/tk.hustoj.com/1347/1347.cpp new file mode 100644 index 00000000..1a712631 --- /dev/null +++ b/tk.hustoj.com/1347/1347.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() { + string s; + getline(cin, s); + vector args; + stringstream ss; + ss << s; + while (ss >> s) { + args.push_back(s); + } + int count = 10; + if (args.size() >= 2) count = -atoi(args[1].c_str()); + while (getline(cin, s)) { + if (count-- > 0) { + cout << s << endl; + } + } + return 0; +} \ No newline at end of file