Решить по информатике. в пяти тестовых опросах мальчик получил оценки. составьте алгоритм и программу которая определит средние значение оценок полученных мальчиком в пяти опросах
Везде значения вводятся с клавиатуры! на java если изучали массив: public class qwert { public static void main(String args[]) { Scanner scn = new Scanner(System.in); int[] a = new int[5]; int k = 0; for (int i = 0; i < 5; i++) { a[i] = scn.nextInt(); k = k + a[i]; if (i == 4) System.out.println(k/i); } }} если не изучали массив: public class qwert { public static void main(String args[]) { Scanner scn = new Scanner(System.in); int a = scn.nextInt(); int b = scn.nextInt(); int c = scn.nextInt(); int d = scn.nextInt(); int e = scn.nextInt(); int s = (a + b + c + d + e) / 5; System.out.println(s); }} на паскале через массив: var a:array [1..5] of integer; i:integer; s:real; begin for i := 1 to 5 do begin readln(a[i]); s := s + a[i]; if i = 5 then write (s/i); end; end. не через масивы: var a,b,c,d,e :integer; s:real; begin readln(a,b,c,d,e); s := (a+b+c+d+e)/5; write(s); end.
Var A,B:real; C:integer; Begin WriteLn('1 - сложение, 2 - вычитание, 3 - умножение, 4 - деление, 0 - выход'); ReadLn(C); While C <> 0 do Begin Write('Введите два числа: '); ReadLn(A,B); Write('ответ: '); Case C of 1:WriteLn(A+B); 2:WriteLn(A-B); 3:WriteLn(A*B); 4:WriteLn(A/B); End; WriteLn('1 - сложение, 2 - вычитание, 3 - умножение, 4 - деление, 0 - выход'); ReadLn(C); End; WriteLn('Пока!'); End.
Вывод результат, точно как в условии:
Var A,B:real; C:integer; Begin WriteLn('1 - сложение, 2 - вычитание, 3 - умножение, 4 - деление, 0 - выход'); ReadLn(C); While C <> 0 do Begin Write('Введите два числа: '); ReadLn(A,B); Write('ответ: '); Case C of 1: if B < 0 then WriteLn(A,B,'=',A+B) else WriteLn(A,'+',B,'=',A+B); 2: if B < 0 then WriteLn(A,'+',-B,'=',A-B) else WriteLn(A,B,'=',A-B); 3: if B < 0 then WriteLn(A,'*(',B,')=',A*B) else WriteLn(A,'*',B,'=',A*B); 4: if B < 0 then WriteLn(A,':(',B,')=',A/B) else WriteLn(A,':',B,'=',A/B); End; WriteLn('1 - сложение, 2 - вычитание, 3 - умножение, 4 - деление, 0 - выход'); ReadLn(C); End; WriteLn('Пока!'); End.
2) каждое из чисел х у z положительно ( x>0) ∧ (y>0) ∧ (z>0) 1) х у z равны между собой (x=y)∨ (x=z) ∨ (y=z) 3) хотя бы одно из чисел х у z отрицательно (x<0)∨ (z<0) ∨ (y<0) 4) хотя бы одно из чисел х у z не является положительным (x<0)∨ (z>0) ∨ (y>0) 5) только одно из чисел х у z не больше 10 (( x<=10) ∧ (y>10) ∧ (z>10)) ∨ ( ( x>10) ∧ (y<=10) ∧ (z>10)) ∨ ( ( x>10) ∧ (y>10) ∧ (z<=10)) 6) ни одно из чисел х у z не равно 104 ¬(x=104)∧ (¬(y=104))∧( ¬(z=104)) ВТОРОЕ ЗАДАНИЕ ПРОВЕРЬ УСЛОВИЕ ЧТО-ТО В НЕМ НЕВЕРНО
на java
если изучали массив:
public class qwert {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int[] a = new int[5];
int k = 0;
for (int i = 0; i < 5; i++) {
a[i] = scn.nextInt();
k = k + a[i];
if (i == 4)
System.out.println(k/i);
}
}}
если не изучали массив:
public class qwert {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int a = scn.nextInt();
int b = scn.nextInt();
int c = scn.nextInt();
int d = scn.nextInt();
int e = scn.nextInt();
int s = (a + b + c + d + e) / 5;
System.out.println(s);
}}
на паскале через массив:
var a:array [1..5] of integer;
i:integer;
s:real;
begin
for i := 1 to 5 do
begin
readln(a[i]);
s := s + a[i];
if i = 5
then
write (s/i);
end;
end.
не через масивы:
var a,b,c,d,e :integer;
s:real;
begin
readln(a,b,c,d,e);
s := (a+b+c+d+e)/5;
write(s);
end.