נערת סמינר
משתמש פעיל
- הוסף לסימניות
- #1
כל פעם שאני מריצה את התוכנית שלי היא נופלת והבעיה בפונקציה הזאת: הוא כל הזמן לא מצליח להציב את temp בbuses
האם אני עושה את זה טוב?
(זאת פונקציה שמוסיפה קו אוטובוס למאגר קווי אוטובוס- שקיים בתוך מערך דינאמי)
אשמח לעזרה, תודה רבה
האם אני עושה את זה טוב?
(זאת פונקציה שמוסיפה קו אוטובוס למאגר קווי אוטובוס- שקיים בתוך מערך דינאמי)
אשמח לעזרה, תודה רבה
void addLine(int** &buses, int &numBuses, int line, int stops, int durationOfRide)
}
bool flag = false;
if (search(buses, numBuses, line) == -1)//send to the search function to check if the line is in the sistem and if not add it to
}
int** temp = new int*[++numBuses];//Creates a new matrix with numBuses + 1 rows and 3 columns
for (int i = 0; i < numBuses; i++)
}
temp = new int[3];
{
if (numBuses == 1)//if temp is empty(numBuses is equal to 1 because I plussed it 1)- put the new line at the firsy place
}
temp[0][0] = line;
temp[0][1] = stops;
temp[0][2] = durationOfRide;
flag = true;
buses = temp;
{
else //if temp is full
}
for (int i = 0, k = 0; i < numBuses - 1; i++, k++)//Transfers the data in the buses array to the temp array
}
if (line < buses[0] && !flag)//if the new line is smaller than the current line in temp
}
temp[k][0] = line;
temp[k][1] = stops;
temp[k][2] = durationOfRide;
k++;
flag = true;
{
for (int j = 0; j < 3; j++)
}
temp[k][j] = buses[j];
{
{
if (!flag)
}
buses[numBuses-1][0] = line;
buses[numBuses-1][1] = stops;
buses[numBuses-1][2] = durationOfRide;
{
{
buses = temp;
if (temp)
}
delete[] temp;
temp = nullptr;
{
{
}
}
bool flag = false;
if (search(buses, numBuses, line) == -1)//send to the search function to check if the line is in the sistem and if not add it to
}
int** temp = new int*[++numBuses];//Creates a new matrix with numBuses + 1 rows and 3 columns
for (int i = 0; i < numBuses; i++)
}
temp = new int[3];
{
if (numBuses == 1)//if temp is empty(numBuses is equal to 1 because I plussed it 1)- put the new line at the firsy place
}
temp[0][0] = line;
temp[0][1] = stops;
temp[0][2] = durationOfRide;
flag = true;
buses = temp;
{
else //if temp is full
}
for (int i = 0, k = 0; i < numBuses - 1; i++, k++)//Transfers the data in the buses array to the temp array
}
if (line < buses[0] && !flag)//if the new line is smaller than the current line in temp
}
temp[k][0] = line;
temp[k][1] = stops;
temp[k][2] = durationOfRide;
k++;
flag = true;
{
for (int j = 0; j < 3; j++)
}
temp[k][j] = buses[j];
{
{
if (!flag)
}
buses[numBuses-1][0] = line;
buses[numBuses-1][1] = stops;
buses[numBuses-1][2] = durationOfRide;
{
{
buses = temp;
if (temp)
}
delete[] temp;
temp = nullptr;
{
{
}
הנושאים החמים