Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- class student {
- public:
- student()
- : surname(L""), name(L""), patronymic(L""), group(L""), point(0)
- { };
- student(wstring _surname, wstring _name, wstring _patronymic, wstring _group, double _point)
- : surname(_surname), name(_name), patronymic(_patronymic), group(_group), point(_point)
- { };
- student(const student &);
- ~student();
- void input();
- void output();
- student operator =(student &);
- private:
- wstring surname;
- wstring name;
- wstring patronymic;
- wstring group;
- double point;
- };
- void ru();
- int main() {
- ru();
- const size_t size = 2;
- student students[size];
- for (size_t n = 0; n < size; n++) students[n].input();
- for (size_t n = 0; n < size; n++) students[n].output();
- student ivanov = student(L"Иванов", L"Игорь", L"Филиппович", L"115а", 4.12);
- ivanov.output();
- cin.get(); cin.get();
- return 0;
- }
- student::~student() {
- group = patronymic = surname = name = L"";
- point = 0;
- }
- student::student(const student & _student) {
- this->surname = _student.surname;
- this->name = _student.name;
- this->patronymic = _student.patronymic;
- this->group = _student.group;
- this->point = _student.point;
- }
- student student::operator =(student & _student) {
- this->surname = _student.surname;
- this->name = _student.name;
- this->patronymic = _student.patronymic;
- this->group = _student.group;
- this->point = _student.point;
- return *this;
- }
- void student::input() {
- wcout << L"Введите фамилия: "; getline(wcin, surname);
- wcout << L"Введите имя: "; getline(wcin, name);
- wcout << L"Введите отчество: "; getline(wcin, patronymic);
- wcout << L"Введите группу: "; getline(wcin, group);
- do {
- wcout << L"Введите средний балл: "; cin >> point;
- if (cin.good() && point > 0) break;
- else {
- cin.clear();
- cin.ignore(80,'\n');
- wcout << L"\aВы ошиблись!\n";
- }
- } while (true);
- fflush(stdin);
- system("cls");
- }
- void student::output() {
- wchar_t v = ' ';
- streamsize accuracy = 2;
- wcout << v << surname
- << v << name
- << v << patronymic
- << v << group
- << v << fixed << setprecision(accuracy) << point << endl;
- }
- void ru() {
- wcout.imbue(locale("rus_rus.866"));
- wcin.imbue(locale("rus_rus.866"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement