Здравствуйте! Помогите, пожалуйста, написать две задачи на языке C. В языке вообще не шарю. За помощь готов предоставить вознаграждение. Ссылка на задачу https://ibb.co/3mcv4m0
№ 4 #include <iostream> using namespace std; bool is_leap(int year) { bool result; if (year % 4 != 0) result = false; else if (0 == year % 400) result = true; else if (0 == year % 100) result = false; else result = true; return result; } int days(int year, int month) { if (month < 1 || month > 12 || year < 1) return 0; int months[]{ 365, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (month != 2 || !is_leap(year)) return months[month]; return 29; } int input(const char* msg) { cout << msg; int value; cin >> value; cin.ignore(0x1000, '\n'); return value; } int main() { const auto year = input("Year: "); const auto month = input("Month: "); const auto quantity = days(year, month); cout << "Quantity: " << quantity << '\n'; } C #include <iostream> using namespace std; bool is_leap(int year) { bool result; if (year % 4 != 0) result = false; else if (0 == year % 400) result = true; else if (0 == year % 100) result = false; else result = true; return result; } int days(int year, int month) { if (month < 1 || month > 12 || year < 1) return 0; int months[]{ 365, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (month != 2 || !is_leap(year)) return months[month]; return 29; } int input(const char* msg) { cout << msg; int value; cin >> value; cin.ignore(0x1000, '\n'); return value; } int main() { const auto year = input("Year: "); const auto month = input("Month: "); const auto quantity = days(year, month); cout << "Quantity: " << quantity << '\n'; } № 2 #include <iostream> using namespace std; int main() { cout << "A: "; double a; cin >> a; cout << "B: "; double b; cin >> b; auto c = a - b; if (b == c) puts("Поровну"); else { puts(b > c ? "Вера" : "Валя"); cout << "На " << fabs(b - c) << " кг\n"; } } C #include <iostream> using namespace std; int main() { cout << "A: "; double a; cin >> a; cout << "B: "; double b; cin >> b; auto c = a - b; if (b == c) puts("Поровну"); else { puts(b > c ? "Вера" : "Валя"); cout << "На " << fabs(b - c) << " кг\n"; } }
@пользователь, мне кажется ты плохо знаешь что плюсы что и си, кроме stdin есть еще double который си к сожалению не всегда берет в принтфе, берет он флоат тип. (может из-за компилятора). и нету авто, ты упомянул, но переписывать под си это будет нелегко с констант и я не знаю что за игнор функция, возможно ее тоже нету. тот кто написал код, он молодец. а ты на подсосе) выучи язык