13年题。

This commit is contained in:
unlockable
2023-06-02 00:03:58 +08:00
parent 955977fef2
commit 9cecf352c2
11 changed files with 401 additions and 0 deletions

27
OOP/13Exam/2.4.cpp Normal file
View 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++;
}
}