C++

C++


массив структур c++




C++


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

#include<iostream>

#include<windows.h> // для system("cls");

using namespace std;

 

struct Size

{

int breast;

int waist;  

int hips;  

};

 

struct WonderfulWoman

{

char name[64];

int age;

int height;

int weight;

Size volume;  

bool engKnowledge;

};

 

void showData(const WonderfulWoman Obj[], int amount);

 

int main()

{

setlocale(LC_ALL, "rus");

 

const int amountOfGirl = 7;

WonderfulWoman Woman[amountOfGirl] = {};

 

for (int i = 0; i < amountOfGirl; i++)

{

cout << "Имя: ";

cin.getline(Woman[i].name, 32);

cout << "Возраст: ";

cin >> Woman[i].age;

cout << "Рост: ";

cin >> Woman[i].height;

cout << "Вес: ";

cin >> Woman[i].weight;

cout << "Английский (1 - да, 0 - нет): ";

cin >> Woman[i].engKnowledge;

cout << "Объемы (грудь, талия, бедра): ";

cin >> Woman[i].volume.breast;

cin >> Woman[i].volume.waist;

cin >> Woman[i].volume.hips;

cin.get(); // считывает из потока Enter который пользователь нажимает после ввода возраста

cout << endl;

}

 

showData(Woman, amountOfGirl);

 

return 0;

}

 

void showData(const WonderfulWoman Obj[], int amount)

{

system("cls"); // сработает только для windows

cout << "№\t" << "Имя\t" << "Возраст\t" << "Рост\t" << "Вес\t" << "Объёмы\t\t" << "Английский" << endl;

cout << "==================================================================" << endl;

for (int i = 0; i < amount; i++)

{

cout << i + 1 << '\t' << Obj[i].name << '\t' << Obj[i].age

<< '\t' << Obj[i].height << '\t' << Obj[i].weight << '\t'

<< Obj[i].volume.breast << '/' << Obj[i].volume.waist << '/' << Obj[i].volume.hips

<< '\t' << Obj[i].engKnowledge << endl;

}

}


Report Page