#include <iostream>
#include <math.h>
#define PI 3.14159
int main()
{
using namespace std;
float a,b,result;
cin>>a>>b;
float result=a+b;
cout<<"Slozhenie a+b = "<<result<<endl;
result=a-b;
cout<<"Raznost a-b ="<<result<<endl;
result=a*b;
cout<<"a*b ="<<result<<endl;
result=a/b;
cout<<"a/b ="<<result<<endl;
result=sin(a*PI/180); //для а в градусах
cout<<"sin(a gradusov) ="<<result<<endl;
result=sin(b); //для b радиан
cout<<"sin(b radian) ="<<result<<endl;
result=sqrt(a*b); //квадратный корень перемножения а*б
cout<<"sqrt(a*b) ="<<result<<endl;
return 0;
}
Два соображения:
Произведение делится на 7, но не делится на 49, если один из сомножителей делится на 7 (но не на 49), а второй - не делится на 7.Произведение будет больше, если каждый из сомножителей будет большеПолучаем такую идею: будем хранить максимальное из всех чисел, делящихся на 7, но не делящихся на 49, и максимальное из чисел, не делящихся на 7. Их произведение будет ответом.
Реализация (Python 3.8.1)
max_div_7 = 0
max_not_div_7 = 0
while (x := int(input())) != 0:
if x % 7 != 0:
max_not_div_7 = max(max_not_div_7, x)
elif x % 7 == 0 and x % 49 != 0:
max_div_7 = max(max_div_7, x)
if max_div_7 == 0 or max_not_div_7 == 0:
print(1)
else:
print(max_div_7 * max_not_div_7)
var a: array [1..5] of integer;
i, j , count, sum_count: integer;
repeated : boolean;
begin
for i := 1 to 5 do
begin
write('Введите ', i, '-e число: ');
readln(a[i]);
end;
sum_count := 0;
for i := 1 to 5 do
begin
repeated := false;
for j := 1 to i - 1 do
begin
repeated := (a[i] = a[j]);
if repeated then break;
end;
if repeated then continue;
count := 1;
for j:= i+1 to 5 do
if (a[i]=a[j]) then
inc(count);
if count > 1 then
sum_count += count;
end;
writeln(sum_count);
end.