/*суммы будем сравнивать по модулю, в ином случае программа не будет иметь смысла, так как сумма отрицательных всегда будет меньше, чем сумма положительных*/
#include <iostream>
#include <cmath>
using namespace std;
void check() {
float s_positive = 0, s_negative = 0, digit;
try {
cout << "Начинайте ввод чисел" << endl;
do {
cin >> digit;
if (digit > 0)
s_positive += digit;
else
s_negative += digit;
} while (digit != 0);
if (s_positive > abs(s_negative))
cout << "Сумма положительных чисел больше!";
else if (abs(s_negative) > s_positive)
cout << "Сумма отрицательных чисел больше!";
else
cout << "Суммы равны по модулю!";
}
catch (...) {
cout << "Ошибка!";
}
}
signed main() {
setlocale(LC_ALL, "Rus");
check();
return 0;
}
1
var
mas:array[1..100] of integer;
i,n:integer;
en,out:text;
res:real;
qw,qwe:string;
begin
n:=0;
i:=1;
write('Введите полный путь к импортируемому файлу: ');readln(qw);
write('Введите полный путь к экспортируемому файлу: ');readln(qwe);
assign(en,qw+'.txt'); assign(out,qwe+'.txt');
reset(en); rewrite(out);
while not Eof(en) do
begin
readln(en,mas[i]);
n:=n+mas[i];
inc(i);
end;
res:=(n/(i-1));
write(out,res);
close(out);
close(en);
end.
Там во вторую тупо добавляешь:
max:=-100001;
min:=100001;
if (mas[i]<0) and (mas[i] mod 2 = 0) and (mas[i]<min) then min:=mas[i];
if (mas[i]>0) and (mas[i] mod 2 = 1) and (mas[i]>max) then max:=mas[i];
if (max=-100001)or(min=100001) then writeln(out,'ERROR: please, rewrite yor file')
else
begin
writeln(out,min);
writeln(out,max);
Тоже такие же задачи решал)) лол). Ты не из 604??)))