Найдите пожалуйста ошибку! Язык C++ #include "stdafx.h"
#include
#include
#include
using namespace std;
typedef struct F
{
int NAME;
int num;
int place;
}car;
int GR(int positionstart, int positionfinish)
{
int a = rand() % (positionfinish - positionstart + 1) + positionstart;
return a;
}
void FillA(car*arr, int*pl)
{
int p;
for(int i = 0; i < 5; i++)
{
int p = GR(1000,9999);
if((arr[0].NAME != p) && (arr[1].NAME != p) && (arr[2].NAME != p) && (arr[3].NAME != p) && (arr[4].NAME != p))
{
arr[i].NAME = p;
}
int p = GR(100000,999999);
if((arr[0].num != p) && (arr[1].num != p) && (arr[2].num != p) && (arr[3].num != p) && (arr[4].num != p))
{
arr[i].num = p;
}
int p = GR(0,5);
if((arr[0].place != p) && (arr[1].place != p) && (arr[2].place != p) && (arr[3].place != p) && (arr[4].place != p))
{
arr[i].place = p;
if(p != 0)
{
pl[p - 1] = arr[i].num = p;
}
}
}
}
void PrintPr(car*arr, int*pl)
{
for(int i = 0; i < 5; i++)
{
cout << pl[i] << '|';
}
for(int i = 0; i < 5; i++)
{
cout << "Name: " << arr[i].NAME << endl << "Number: " << arr[i].num << endl << "Place: " << arr[i].place << endl;
}
}
int main()
{
srand(time(0));
car*arr = new car[5];
int*pl = new int[5];
int p;
FillA(arr, pl);
cout << "Enter place --> ";
cin >> p;
if((arr[0].place != p) && (arr[1].place != p) && (arr[2].place != p) && (arr[3].place != p) && (arr[4].place != p))
{
cout << "There are no cars.";
}
else
{
cout << "There are car with num " << pl[p];
}
if((pl[0] != 0) && (pl[1] != 0) && (pl[2] != 0) && (pl[3] != 0) && (pl[4] != 0))
{
cout << "There are no free places!";
}
else
{
cout << "There are no free places!";
}
cout << endl;
system("pause");
PrintPr(arr, pl);
cout << endl;
system("pause");
return 0;
}