2020-09-11 10:43:12 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2020-09-19 11:41:40 +00:00
|
|
|
class Student {
|
2020-09-11 10:43:12 +00:00
|
|
|
uint number;
|
|
|
|
string first_name;
|
|
|
|
string second_name;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Student(uint num, string first, string second)
|
|
|
|
{
|
|
|
|
number = num;
|
|
|
|
first_name = first;
|
|
|
|
second_name = second;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint first_var(uint num_of_vars)
|
|
|
|
{
|
2020-09-19 11:41:40 +00:00
|
|
|
if (num_of_vars == 0) {
|
2020-09-11 10:43:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return number % num_of_vars;
|
|
|
|
}
|
|
|
|
uint second_var(uint num_of_vars)
|
|
|
|
{
|
2020-09-19 11:41:40 +00:00
|
|
|
if (num_of_vars == 0) {
|
2020-09-11 10:43:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (uint)first_name.front() % num_of_vars;
|
|
|
|
}
|
|
|
|
uint third_var(uint num_of_vars)
|
|
|
|
{
|
2020-09-19 11:41:40 +00:00
|
|
|
if (num_of_vars == 0) {
|
2020-09-11 10:43:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (uint)second_name.front() % num_of_vars;
|
|
|
|
}
|
|
|
|
|
2020-09-19 11:41:40 +00:00
|
|
|
void print_name()
|
|
|
|
{
|
2020-09-11 10:43:12 +00:00
|
|
|
cout << number << ". " << first_name << " " << second_name << "\n";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
uint num_of_vars = 6;
|
|
|
|
cout << "Вариантов: " << num_of_vars << "\n";
|
|
|
|
|
|
|
|
Student a = Student(3, "Алексей", "Хвойный");
|
|
|
|
a.print_name();
|
|
|
|
cout << "Первый тип варианта: " << a.first_var(num_of_vars) << "\n";
|
|
|
|
cout << "Второй тип варианта: " << a.second_var(num_of_vars) << "\n";
|
|
|
|
cout << "Третий тип варианта: " << a.third_var(num_of_vars) << "\n";
|
2020-09-19 11:41:40 +00:00
|
|
|
|
2020-09-11 10:43:12 +00:00
|
|
|
Student b = Student(4, "Иван", "Олегович");
|
|
|
|
b.print_name();
|
|
|
|
cout << "Первый тип варианта: " << b.first_var(num_of_vars) << "\n";
|
|
|
|
cout << "Второй тип варианта: " << b.second_var(num_of_vars) << "\n";
|
|
|
|
cout << "Третий тип варианта: " << b.third_var(num_of_vars) << "\n";
|
|
|
|
return 0;
|
|
|
|
}
|