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("Увы, но пройти Вам нельзя!");
}
}
}
#include <iostream>
using namespace std;
class circle {
public:
int x, y;
double r, s;
circle()
{
x = 0;
y = 0;
r = 0;
}
circle( int a = 0, int b = 0, double c = 0 )
{
set(a, b, c);
}
void out()
{
cout << "Координаты: (" << x << ", " << y << ") Радиус: "<< r << " Площадь: " << endl;
}
void set(int a, int b, double c)
{
x = a;
y = b;
r = c;
}
void calculate() {
s = r * r * 3.14159;
}
};
class sphere : public circle {
private:
double v;
void calculate() {
s = 4 * 3.14 * r * r;
v = 3.14159 * pow(r, 3);
}
public:
sphere();
sphere() : circle(circle, double = 1.0);
sphere (int = 0, int = 0, double = 1.0) ;
void out()
{
circle::out();
cout << ", радиус: " << r << ", длина: " << ", площадь: " << s;
}
};
int main(){
setlocale(LC_ALL, "ru");
circle a(2, 15, 4);
a.out();
sphere b;
system("pause");
return 0;
}
Объяснение: пойдёт?