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

26
OOP/13Exam/2.3.cpp Normal file
View File

@@ -0,0 +1,26 @@
// 在给出的时间类Time中增加show_time函数以时秒的格式显示时间。
#include <iostream>
using namespace std;
class Time {
public:
Time(int h, int m, int s) {
hour = h, minute = m, sec = s;
}
// ______________________
// {_______________________}
void show_time() {
cout << hour << ":" << minute << ":" << sec << endl;
}
private:
int hour, minute, sec;
};
int main() {
Time T(5, 0, 0);
T.show_time();
return 0;
}