Решение 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;
}
Объяснение:
using System;
namespace restless
{
class Visitor
{
private bool ticket;
private int age;
private int height;
public void InputInfo()
{
c:
Console.Write("Наличие билета: (Да/Нет): ");
string t = Console.ReadLine().ToLower();
if (t == "да")
ticket = true;
else if (t == "нет")
ticket = false;
else
{
Console.WriteLine("Вы ввели что-то не то...");
goto c;
}
Console.Write("Ваш возраст: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("Ваш рост: ");
height = Convert.ToInt32(Console.ReadLine());
}
public bool CheckPeople()
{
if (ticket == true && age > 15 && height > 120)
return true;
return false;
}
}
class Program
{
static void Main(string[] args)
{
Visitor ch1 = new Visitor();
ch1.InputInfo();
if (ch1.CheckPeople())
Console.WriteLine("Вам можно пройти!");
else
Console.WriteLine("Увы, но пройти Вам нельзя!");
}
}
}
Решение на картинке:
k = 3.