Если числа из условия записаны в переменные rank, score, passingScore, russianLanguage, то получение можно получить, если:
rank ≤ 10 или score ≥ passingScore и russinaLanguage = 1
В C++ ИЛИ обозначается как ||, а И - как &&.
Код (C++):
#include <iostream>
int main() {
int rank, score, passingScore, russianLanguage;
std::cin >> rank >> score >> passingScore >> russianLanguage;
if ((rank <= 10) || ((score >= passingScore) && (russianLanguage == 1))) {
std::cout << "YES";
} else {
std::cout << "NO";
}
}
Решение Pascal
Delphi/Pascal
program Case5;
var
N,A,B:Integer;
begin
Write('Введите номер действия: ');
Readln(N);
Write('Введите число A: ');
Readln(A);
Write('Введите число B: ');
Readln(B);
Case N of
1: Writeln(A+B);
2: Writeln(A-B);
3: Writeln(A*B);
4: Writeln(A/B);
end;
end.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program Case5;
var
N,A,B:Integer;
begin
Write('Введите номер действия: ');
Readln(N);
Write('Введите число A: ');
Readln(A);
Write('Введите число B: ');
Readln(B);
Case N of
1: Writeln(A+B);
2: Writeln(A-B);
3: Writeln(A*B);
4: Writeln(A/B);
end;
end.
Решение C
C
#include <stdio.h>
int main(void)
{
system("chcp 1251");
int n;
float a,b;
printf("N:") ;
scanf ("%i", &n);
printf("A:") ;
scanf ("%f", &a);
printf("B:") ;
scanf ("%f", &b);
switch (n) {
case 1:
printf("%f\n",a+b) ;
break;
case 2:
printf("%f\n",a-b) ;
break;
case 3:
printf("%f\n",a*b) ;
break;
case 4:
printf("%f\n",a/b) ;
break;
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
int main(void)
{
system("chcp 1251");
int n;
float a,b;
printf("N:") ;
scanf ("%i", &n);
printf("A:") ;
scanf ("%f", &a);
printf("B:") ;
scanf ("%f", &b);
switch (n) {
case 1:
printf("%f\n",a+b) ;
break;
case 2:
printf("%f\n",a-b) ;
break;
case 3:
printf("%f\n",a*b) ;
break;
case 4:
printf("%f\n",a/b) ;
break;
}
return 0;
}
Объяснение:
n1:real;
begin
sum:=0;
repeat
writeln ('Введите число');
readln(n1);
until (n1>0)and(n1=round(n1));
n:=round(n1);
for del:=1 to n-1 do//ищем делители включая единицу и исключая само число
begin
if (n mod del=0) then //если делится
sum:=sum+del; //учитываем в сумме
end;
if sum=n then writeln('Да')
else writeln('Нет')
end.
Вроде так, если я не сильно упорота