13年题。
This commit is contained in:
27
OOP/13Exam/2.4.cpp
Normal file
27
OOP/13Exam/2.4.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// 已知文件test.txt的内容如下:
|
||||
// Good Morning!
|
||||
// Good Night!
|
||||
// Good Luck!
|
||||
// 补充下面程序,使得输出结果如下:
|
||||
// 1:Good Morning!
|
||||
// 2:Good Night!
|
||||
// 3:Good Luck!
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
const int size = 100;
|
||||
int main() {
|
||||
char buf[::size];
|
||||
// _______________
|
||||
|
||||
ifstream in("test.txt", ios::in);
|
||||
|
||||
int i = 1;
|
||||
while (in.getline(buf, ::size)) {
|
||||
// ____________________
|
||||
|
||||
cout << i <<":" << buf << endl;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user