Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include<windows.h>
- #include <vector>
- #include <conio.h>
- using namespace std;
- #define Today 30
- #define ToMonth 04
- #define ToYear 2018
- struct Uch {
- char F[10];
- char I[10];
- char O[10];
- int Data; int Month; int Year;
- };
- int AllAge=0;
- int Age = 0;
- int i = 0;
- Uch* L(Uch*L, const int amount);
- void setData(Uch*L, const int amount);
- void showData(const Uch*L, const int amount);
- int main()
- {
- Uch* FUch = 0;
- int uchAmount = 0;
- int YesOrNot = 0;
- do {
- FUch = L(FUch, uchAmount);
- setData(FUch, uchAmount);
- uchAmount++;
- cout << "Continue 1-yes 0-no";
- cin >> YesOrNot;
- cin.get();
- } while (YesOrNot == 1);
- showData(FUch, uchAmount);
- delete[] FUch;
- system("pause");
- return 0;
- }
- Uch*L(Uch*M, const int amount) //подфункция добавления новых членов
- {
- if (amount == 0)
- {
- M = new Uch[amount + 1];
- }
- else
- {
- Uch*tempM = new Uch[amount + 1];
- for (int i = 0; i < amount; i++)
- {
- tempM[i] = M[i];
- }
- delete[] M;
- M = tempM;
- }
- return M;
- }
- void setData(Uch*M, const int amount) // ввод значений и вывод их пользователю
- {
- cout << "vvod familii ";
- cin.getline(M[amount].F, 10);
- cout << "vvod name ";
- cin.getline(M[amount].I, 10);
- cout << "vvod otchestvo ";
- cin.getline(M[amount].O, 10);
- cout << "day of birth ";
- cin>>M[amount].Data;
- cout << "month ";
- cin>> M[amount].Month;
- cout << "year ";
- cin>>M[amount].Year;
- cin.get();
- cout << endl;
- }
- void showData(const Uch*M, const int amount ) //вывод значений в табличке
- {
- cout << "vozrast " << Age<<endl;
- int uchAmount = 0;
- Uch *FUch = 0;
- FUch = L(FUch, uchAmount);
- uchAmount++;
- system("cls");//очистка экр
- cout << "№ " << "surn\t " << " Name\t" << " OTCH\t" << " DATA\t" << " month\t" << " year\t" <<"Age "<< endl;
- cout << "======>\n\n" << endl;
- for (int i = 0; i < amount; i++)
- {
- Age = ToYear - M[i].Year;
- cout<<i+1<<" "<<M[i].F << "\t" << M[i].I << "\t" << M[i].O <<"\t"<<M[i].Data<<"\t"<<M[i].Month<<"\t"<<M[i].Year<<"\t"<<Age<<"\t"<< endl;
- AllAge +=Age ;
- }
- cout << "MidleAge" << AllAge/(amount) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement