Код:
#include <iostream>
using namespace std;
void findDayOfWeek(int day) {
switch (day) {
case 1:
cout << "Понедельник";
break;
case 2:
cout << "Вторник";
case 3:
cout << "Среда";
case 4:
cout << "Четверг";
case 5:
cout << "Пятница";
case 6:
cout << "Суббота";
case 7:
cout << "Воскресенье";
default:
findDayOfWeek(day - 7);
}
int main() {
setlocale(0, "RU");
int day;
cin >> day;
findDayOfWeek(day);
return 0;
Код:
#include <fstream>#include <cmath>void first_task(std::ifstream &cin, std::ofstream &cout) { int n, k = 1; cin >> n >> k; cout << n / k;}void second_task(std::ifstream &cin, std::ofstream &cout) { int N; cin >> N; cout << 2 * (N / 2 + 1);}void third_task(std::ifstream &cin, std::ofstream &cout) { int N; cin >> N; auto t = [](int c, int N){return c / (int) pow(10, N) % 10;}; cout << t(N, 2) + t(N, 1) + t(N, 0);}void fourth_task(std::ifstream &cin, std::ofstream &cout) { int N; cin >> N; for (int it = 0; it < log2(N); ++it) { cout << pow(2, it) << " "; }}void fifth_task(std::ifstream &cin, std::ofstream &cout) { int h, a, b; cin >> h >> a >> b; int h0 = h - a, dx = a - b; int g = 1 + h0/dx + (h0%dx + dx - 1)/dx; if (g < 0) cout << INFINITY; else cout << g;}int main() { std::ifstream cin("input.txt"); std::ofstream cout("output.txt"); // Choose your function int N = 0; // 0-4 void (*tasks[5]) (std::ifstream &, std::ofstream &) = {first_task, second_task, third_task, fourth_task, fifth_task}; tasks[N](cin, cout); return 0;}#include <iostream>
using namespace std;
void findDayOfWeek(int day) {
switch (day) {
case 1:
cout << "Понедельник";
break;
case 2:
cout << "Вторник";
break;
case 3:
cout << "Среда";
break;
case 4:
cout << "Четверг";
break;
case 5:
cout << "Пятница";
break;
case 6:
cout << "Суббота";
break;
case 7:
cout << "Воскресенье";
break;
default:
findDayOfWeek(day - 7);
}
}
int main() {
setlocale(0, "RU");
int day;
cin >> day;
findDayOfWeek(day);
return 0;
}