C++ 类的简单运用。
#include <bits/stdc++.h> using namespace std; class time{ private: int year, month, day; public: void set(int a, int b, int c) { year = a; month = b; day = c; } void print() { printf("%d:%d:%d", year, month, day); } }; int main() { int a, b, c; scanf("%d-%d-%d", &a, &b, &c); struct time temp; temp.set(a, b, c); temp.print(); return 0; }
0.0分
0 人评分