Advertisement
Sukaburjuaznaya

ОБОЖЕЭТАЛАБА

Apr 24th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include<windows.h>
  5. #include <vector>
  6. #include <conio.h>
  7. using namespace std;
  8.  
  9. #define Today 30
  10. #define ToMonth 04
  11. #define ToYear 2018
  12.  
  13. struct Uch {
  14.         char F[10];
  15.         char I[10];
  16.         char O[10];
  17.         int Data; int Month; int Year;
  18. };
  19. int AllAge=0;
  20. int Age = 0;
  21. int i = 0;
  22. Uch* L(Uch*L, const int amount);
  23. void setData(Uch*L, const int amount);
  24. void showData(const Uch*L, const int amount);
  25. int main()
  26. {
  27.     Uch* FUch = 0;
  28.     int uchAmount = 0;
  29.     int YesOrNot = 0;
  30.     do {
  31.         FUch = L(FUch, uchAmount);
  32.         setData(FUch, uchAmount);
  33.         uchAmount++;
  34.         cout << "Continue 1-yes 0-no";
  35.         cin >> YesOrNot;
  36.         cin.get();
  37.     } while (YesOrNot == 1);
  38.     showData(FUch, uchAmount);
  39.     delete[] FUch;
  40.     system("pause");
  41.     return 0;
  42. }
  43. Uch*L(Uch*M, const int amount) //подфункция добавления новых членов
  44. {
  45.     if (amount == 0)
  46.     {
  47.         M = new Uch[amount + 1];
  48.     }
  49.     else
  50.     {
  51.         Uch*tempM = new Uch[amount + 1];
  52.         for (int i = 0; i < amount; i++)
  53.         {
  54.             tempM[i] = M[i];
  55.         }
  56.         delete[] M;
  57.         M = tempM;
  58.     }
  59.     return M;
  60. }
  61. void setData(Uch*M, const int amount) // ввод значений и вывод их пользователю
  62. {
  63.     cout << "vvod familii  ";
  64.     cin.getline(M[amount].F, 10);
  65.     cout << "vvod name  ";
  66.     cin.getline(M[amount].I, 10);
  67.     cout << "vvod otchestvo  ";
  68.     cin.getline(M[amount].O, 10);
  69.     cout << "day of birth  ";
  70.     cin>>M[amount].Data;
  71.     cout << "month   ";
  72.     cin>> M[amount].Month;
  73.     cout << "year  ";
  74.     cin>>M[amount].Year;
  75.     cin.get();
  76.     cout << endl;
  77. }  
  78. void showData(const Uch*M, const int amount ) //вывод значений в табличке
  79. {
  80.     cout << "vozrast  " << Age<<endl;
  81.     int uchAmount = 0;
  82.     Uch *FUch = 0;
  83.     FUch = L(FUch, uchAmount);
  84.     uchAmount++;
  85.     system("cls");//очистка экр
  86.     cout << "№     " << "surn\t   " << "  Name\t" << "   OTCH\t" << "   DATA\t" << "  month\t" << "  year\t" <<"Age  "<< endl;
  87.     cout << "======>\n\n" << endl;
  88.     for (int i = 0; i < amount; i++)
  89.     {
  90.     Age = ToYear - M[i].Year;
  91.     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;
  92.     AllAge +=Age ;
  93.     }  
  94.     cout << "MidleAge" << AllAge/(amount) << endl;
  95.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement