с++ 9) пользователь вводит четыре целых числа вывести среднего арифметическое максимального и минимального из них 10) пользователь вводит количество целых чисел, затем сами числа вывести среднего арифметическое максимального и минимального из них
Високосные года уже не учитывал (найдёте ошибку - не поленитесь написать в комменты)
var a,b,c:integer; begin writeln ('Введите сегодняшний день, месяц, год (например, 1 12 2013)'); read(a,b,c); if (((b=1) or (b=3)or (b=5) or (b=7) or (b=8) or (b=10) or (b=12)) and ((a>=1) and (a<=31))) or ((b=2) and ((a>=1) and (a<=28)) or (((b=4) or (b=6)or (b=9) or (b=11))) and ((a>=1) and (a<=30))) then begin writeln ('Сегодня ',a,'.',b,'.',c); if (((b=1) or (b=3)or (b=5) or (b=7) or (b=8) or (b=10) or (b=12)) and ((a>=1) and (a<=31))) and ((a=31) and (b=12)) then writeln ('Завтра 1.1.',c+1) else if (((b=1) or (b=3)or (b=5) or (b=7) or (b=8) or (b=10) or (b=12)) and ((a>=1) and (a<=31))) and ((a=31) and (b<>12)) then writeln ('Завтра 1.',b+1,'.',c) else if (((b=1) or (b=3)or (b=5) or (b=7) or (b=8) or (b=10) or (b=12)) and ((a>=1) and (a<=31))) and ((a<>31) and (b=12)) then writeln ('Завтра ',a+1,'.',b,'.',c) else if ((b=2) and ((a>=1) and (a<=28))) and ((a=28) and (b=12)) then writeln ('Завтра 1.1.',c+1) else if ((b=2) and ((a>=1) and (a<=28))) and ((a=28) and (b<>12)) then writeln ('Завтра 1.',b+1,'.',c) else if ((b=2) and ((a>=1) and (a<=28))) and ((a<>28) and (b=12)) then writeln ('Завтра ',a+1,'.',b,'.',c) else if (((b=4) or (b=6) or (b=9) or (b=11))) and ((a>=1) and (a<=30)) and ((a=30) and (b=12)) then writeln ('Завтра 1.1.',c+1) else if (((b=4) or (b=6) or (b=9) or (b=11))) and ((a>=1) and (a<=30)) and ((a=30) and (b<>12)) then writeln ('Завтра 1.',b+1,'.',c) else if (((b=4) or (b=6) or (b=9) or (b=11))) and ((a>=1) and (a<=30)) and ((a<>30) and (b=12)) then writeln ('Завтра ',a+1,'.',b,'.',c) else writeln ('Завтра ',a+1,'.',b,'.',c); end else writeln ('Неправильная дата'); end.
int main() { setlocale (LC_ALL,"Russian"); int number; do { cout <<"Введите номер группы: "; cin >> number; } while (number<100 || number>999); char *groups[9]={"исторический","экономический","юридический", "математический","физический","химический", "биологический","географический","географический"}; cout <<groups[number/100-1] <<", поступил в 200" <<number/10%10 <<" году\n"; return 0; } Как задание понял, так и написал
1) #include <iostream>
#include <algorithm>
using namespace std;
int main() {
vector<float> arr;
float temp;
for(int i = 0; i<4; ++i) {
cout << "Num #" << i+1 << ": ";
cin >> temp;
arr.push_back(temp);
}
sort(arr.begin(), arr.end());
cout << endl << (arr[0] + arr[arr.size()-1]) / 2;
}
2) #include <iostream>
#include <algorithm>
using namespace std;
int main() {
vector<float> arr;
float temp, amount;
cout << "amount: ";
cin >> amount;
for(int i = 0; i<amount; ++i) {
cout << "Num #" << i+1 << ": ";
cin >> temp;
arr.push_back(temp);
}
sort(arr.begin(), arr.end());
cout << endl << (arr[0] + arr[arr.size()-1]) / 2;
}