Documente Academic
Documente Profesional
Documente Cultură
Temă Programare - Bolohan Stefan
Temă Programare - Bolohan Stefan
Student:
Grupa:
Programul surs:
// livraripiese.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
#define NUM_ORASE 11
#define MAX_INT 65535
#define NUM_PIESE 25
#define NUM_MASINI 3
class autoutilitara
{
public:
autoutilitara(char* nr_inmatric, int sarc, int vol): sarcina(sarc), volum(vol)
{
strcpy(nr_inmatriculare, nr_inmatric);
}
~autoutilitara()
{
}
char nr_inmatriculare[7];
int sarcina;
int volum;
};
class oras
{
public:
oras()
{}//constructor null
char nume[20];
char index;//indexul in vectorul de orase
};
class piesa
{
public:
piesa(int greut, int vol,int indexdest):greutate(greut), volum(vol), dest(indexdest)
{
}
int greutate;
int volum;
int dest;
};
class graf
{
public:
graf(unsigned short m_distante[], char nume_orase[][20])
{
char i;
memcpy(distante,m_distante,NUM_ORASE*NUM_ORASE*sizeof(unsigned
short) );
orase= new oras[NUM_ORASE];
for (i=0;i<NUM_ORASE;i++)
{
orase[i].index=i;
strcpy(orase[i].nume, nume_orase[i]);
}
unsigned short distante[NUM_ORASE][NUM_ORASE];
oras* orase;
void FindShortestPath(piesa** piese,autoutilitara** autoutil );
if((masa_totala>= autoutil[k]->sarcina)||(volum_total>=autoutil[k]>volum))
if(index>indexintoarcere)
first=indexintoarcere;
traseu[index++]=first;
else
}
{
indexintoarcere=second;
previous= first;
first= second;
traseu[index++]= second;
printf("mergem in orasul %s pe distanta
%d\n\r",orase[second].nume, cost );
}
}
}
unsigned short
matr_distante[]=//MATRICE SIMETRICA
{0, 100, 50, 85, MAX_INT, MAX_INT, 110, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
100, 0, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 100, MAX_INT, 350, 400, MAX_INT,
50, MAX_INT, 0, MAX_INT, 70, MAX_INT, 50, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
85, MAX_INT, MAX_INT, 0, 50, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
MAX_INT, MAX_INT, 70, 85, 0, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 0, 250, 110, MAX_INT, MAX_INT, 150,
110, 100, 50, MAX_INT, MAX_INT, 250, 0, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 110, MAX_INT, 0, MAX_INT, MAX_INT, 140,
MAX_INT, 350, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 0, 200, MAX_INT,
MAX_INT, 400, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 200, 0, 320,
MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 150, MAX_INT, 140, MAX_INT, 320, 0 };
unsigned int
volum_piesa[25]={10, 30, 240, 140, 10, 80, 35, 100, 240, 100, 230, 100, 320, 40, 20, 150,
140, 100, 90, 200, 210, 30, 100, 14, 20};
unsigned int
greutate[]={4, 7, 10, 79, 267, 460, 2, 50, 200, 16, 25, 10, 300, 10, 149, 170, 8, 275, 10, 20,
29, 126, 16, 266, 76};
unsigned int
destinatie[]={1,2,3,4,5,6,7,8,9,10,6,9,5,8,10,4,2,7,4,8,1,9,3,6,9};
char nume_orase[][20]=
{
{"BUCURESTI"},//ORASUL DE PLECARE
{"PITESTI"},
{"PLOIESTI"},
{"TARGOVISTE"},
{"SINAIA"},
{"BACAU"},
{"BUZAU"},
{"IASI"},
{"TARGU MURES"},
{"CLUJ NAPOCA"},
{"SUCEAVA"}
};
char numar_inmatric[3][7]=
{
{"B01PSE"},
{"B02PSE"},
{"B03NUV"}
};
unsigned short sarcina[3]=//kg
{
2000,
2000,
2500
};
unsigned short volum[3]=//l
{
4000,
4000,
5000
};
Descrierea programului:
Programul a fost rulat folosind o matrice de distane construit innd cont de un
numr de 11 orase i distanele dintre ele. Matricea are dimensiunea 11x11 i
este simetric. Distana de la un ora la el nsui este 0, iar oraele neconectate
prin drum direct au distana maxima MAXINT=65535. Oraele sunt prezentate
n vectorul char nume_orase[][20]=
{
{"BUCURESTI"},//ORASUL DE PLECARE, {"PITESTI"},{"PLOIESTI"},{"TARGOVISTE"},
{"SINAIA"},
{"BACAU"},{"BUZAU"},{"IASI"},{"TARGU MURES"},{"CLUJ NAPOCA"},{"SUCEAVA"}};
Matricea distanelor este: {0, 100, 50, 85, MAX_INT, MAX_INT, 110, MAX_INT, MAX_INT,
MAX_INT, MAX_INT,
100, 0, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 100, MAX_INT, 350, 400, MAX_INT,
50, MAX_INT, 0, MAX_INT, 70, MAX_INT, 50, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
85, MAX_INT, MAX_INT, 0, 50, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
MAX_INT, MAX_INT, 70, 85, 0, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 0, 250, 110, MAX_INT, MAX_INT, 150,
110, 100, 50, MAX_INT, MAX_INT, 250, 0, MAX_INT, MAX_INT, MAX_INT, MAX_INT,
MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 110, MAX_INT, 0, MAX_INT, MAX_INT, 140,
MAX_INT, 350, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 0, 200, MAX_INT,
MAX_INT, 400, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 200, 0, 320,
MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 150, MAX_INT, 140, MAX_INT, 320, 0 };
2500
};
unsigned short volum[3]=//l
{
4000,
4000,
5000}