2.
Compile program functions for:
-Enter of a keyboard and a file into an array (by adding) data to 30 girls in the competition "Miss World"
number, name, surname, date of birth, physical data, state and display the current contents of the array on the screen
-display output data for a girl by entered from the keyboard a number and surname / by request
a new report /
-Displays data for the youngest girl in the competition and the number of girls under the age of 20 years
Home-function main () menu selection functions and check the status of the data using the Global
variables or functions with transmission parameters, optional
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
#include <iostream>
#include <cstdio>
#include <conio.h>
#include <cstdlib>
#include <cstring>
using namespace std;
#define N 30 //max girls
struct girl
{
char number[10];
char name[10];
char family[10];
int age;
float height;
float weight;
char country[3];
} ;
girl d[N];
int top=0;
void input();
void disp(int i);
void list();
void teen();
void youngest(girl d[N]);
void showgirl(girl d[N]);
int menu();// menu
void input()
{int i, n;
do
{
cout<<"\n What is number of girls?: ";
cin>>n;
}
while (n<1||n>N);
fflush(stdin);
for(i=top;i<n;i++)
{
cout<<"\n Number: ";
cin>>d[i].number;
cout<<"\n name: ";
cin>>d[i].name;
cout<<"\n Familiy: ";
cin>>d[i].family;
cout<<"\n Age: ";
cin>>d[i].age;
cout<<"\n Height(cm): ";
cin>>d[i].Height;
cout<<"\n Wiight(kg): ";
cin>>d[i].weight;
cout<<"\n Country: ";
cin>>d[i].country;
}
top+=n;
}
void disp(int i) //display 1 girl
{
cout<<"\n "<<d[i].number<<"\t"<<d[i].name<<"\t"<<d[i].family<<"\t"<<d[i].age<<"\t"<<d[i].height<<"\t"
<<d[i].weight<<"\t"<<d[i].country<<endl;
}
void list() //
{
int i;
cout<<"\n List of girls\n";
for(i=0;i<top;i++)
disp(i);}
void teen()
{
int i;
cout<<"\n List of girls under 20\n";
for(i=0;i<top;i++)
{d[i].age*=1;
if(d[i].age<20)
disp(i);
}
}
void youngest(girl d[N])
{
girl max; int k;
max.age = d[0].age;
for (int i = 1;i < k ; i++)
if (d[i].age > max.age)
max = d[i];
cout << "Youngest girl is "<< max.ime << max.family << max.age << max.visochina << max.teglo << max.country;}
void showgirl(girl d[N])
{
char nomer[10];char family[20];int i;
cout<<"Enter number"<<endl;
cin>>nomer;
cout<<"Enter family"<<endl;
cin>>family;
if(!(strcmp(d[i].number,number))&&!(strcmp(d[i].family,family)))
cout<<"The girl is "<<i;
}
int menu()
{
int ch;
cout<<"\n_______________MENU________________";
cout<<"\n 1. Input number of girls";
cout<<"\n 2. List of all girls";
cout<<"\n 3. List of girls under 20";
cout<<"\n 4. Data for 1 girl by entered nomber and family";
cout<<"\n 5. Youngest girl";
cout<<"\n 6. Exit";
do
{
cout<<"\n Choice: ";
cin>>ch;
}
while(ch<1||ch>7);
return(ch);
}
int main()
{
int i;
do
{
i=menu();
switch(i)
{
case 1: input();break;
case 2: list();break;
case 3: teen();break;
case 4: showgirl(d);break;
case 5: youngest(d);break;
}
}
while(i!=6);
return 0;
}
|
In function youngest the console say :
Youngest girl is: G125.88696e-0396.55965e-039-what is wrong with this function?In function showgirl when i call function and nothing happen-this function is wrong too-where is mymistakes in theese two functions
Sorry for bad english im beginner in c++ and only these 2 functions didntI want some help