2):
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
int y;
char buffer[80];
cout << "Year = ";
cin >> y;
tm time_in;
time_in.tm_sec = 0; // second
time_in.tm_min = 0; // minute
time_in.tm_hour = 0; // hour
time_in.tm_mday = 1; // 1-based day
time_in.tm_mon = 9; // 0-based month
time_in.tm_year = y - 1900; // year since 1900
time_t time_temp = mktime (&time_in); // Convert the local time to a calendar value.
tm* time_out = localtime (&time_temp); // Converts a time_t time value to a tm structure
if (time_out->tm_wday > 0) // if it is not Sunday, go to the next Sunday
time_out->tm_mday += 7 - time_out->tm_wday;
strftime(buffer, 80, "%d.%m.%Y", time_out); // date formatting for output
cout << "\nTeachers day is " << buffer << "\n";
}
Объяснение: explanations in the comments to the program
#include <iostream>
using namespace std;
class Building {
private:
string adress_m;
int storeyCount_m;
bool quarantine_m;
public:
Building(string adress = "", int count = -1) {
adress_m = adress;
storeyCount_m = count;
}
void addStoreys(int count) {
storeyCount_m += count;
}
void quarantineOn() {
cout << "Quarantine: on";
cout << endl;
quarantine_m = 1;
}
void quarantineOff() {
cout << "Quarantine: off";
cout << endl;
quarantine_m = 0;
}
void quarantineCheck() {
cout << "Quarantine: ";
if(quarantine_m) {
cout << "on";
cout << endl;
} else {
cout << "off";
cout << endl;
}
}
string getAdress() {
return adress_m;
}
int getStorey() {
return storeyCount_m;
}
};
int main() {
Building build("dirt house", 1);
cout << build.getAdress() << " " << build.getStorey() << " storeys" << " " << endl;
build.quarantineCheck();
build.quarantineOn();
build.addStoreys(2);
cout << build.getAdress() << " " << build.getStorey() << " storeys" << " " << endl;
}