68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
class Student
|
|
{
|
|
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)
|
|
{
|
|
if (num_of_vars == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
return number % num_of_vars;
|
|
}
|
|
uint second_var(uint num_of_vars)
|
|
{
|
|
if (num_of_vars == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
return (uint)first_name.front() % num_of_vars;
|
|
}
|
|
uint third_var(uint num_of_vars)
|
|
{
|
|
if (num_of_vars == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
return (uint)second_name.front() % num_of_vars;
|
|
}
|
|
|
|
void print_name () {
|
|
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";
|
|
|
|
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;
|
|
} |