Commit aee25d5e authored by Chemspro's avatar Chemspro
Browse files

quelques correction et ajout nom-pos des gares

parent 04ae6734
,manfrin,m,06.05.2022 18:52,file:///home/manfrin/.config/libreoffice/4;
\ No newline at end of file
,missou,missou-PC,08.05.2022 16:53,file:///home/missou/.config/libreoffice/4;
\ No newline at end of file
CC=g++
CFLAGS=-I. -std=c++17 -Wall -Wextra -g
CFLAGS=-I. -std=c++17 -Wall -Wextra -g -fsanitize=address,leak
DEPS =
OBJ = main.cpp
OBJ = main.o
%.o: %.cpp $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
m: $(OBJ)
main: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)
.PHONY: clean
clean:
rm *.o m
\ No newline at end of file
rm *.o main
......@@ -9,6 +9,7 @@
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
typedef std::pair<uint,uint> arete;
......@@ -39,11 +40,11 @@ class Graph
void affichage(void)
{
for(int i=0;i<aretes.size();i++)
for(size_t i=0;i<aretes.size();i++)
{
liste_adjacences temp = aretes[i];
cout << "Sommet " << i << " contient: ";
for(int k=0;k<aretes[i].size();k++)
for(size_t k=0;k<aretes[i].size();k++)
{
arete a = temp.front();
cout << "(" << i << "->" << a.first << "|poids:" << a.second << ") ";
......@@ -98,9 +99,8 @@ int main(void)
fstream destination("destination.csv", ios::in);
fstream temps("temps.csv", ios::in);
vector<string> gares;
vector<string> tem;
vector<string> gares,tem;
std::unordered_map<int,string> npgares;
while(origine.good())
{
string o;
......@@ -114,6 +114,11 @@ int main(void)
}
int sz = gares.size();
cout << sz << endl;
for(int i = 0; i < sz;i++)
npgares[i] = gares[i];
cout << endl;
gares.pop_back();
Graph maille(sz);
......@@ -127,12 +132,11 @@ int main(void)
}
tem.pop_back();
int count = 0;
size_t count = 0;
while(destination.good()&&count<tem.size())
while(destination.good() && count<tem.size())
{
string o;
string d;
string o,d;
int i = stoi(tem.at(count));
getline(origine2,o);
......@@ -140,15 +144,17 @@ int main(void)
auto it = find(gares.begin(), gares.end(), o);
auto it2 = find(gares.begin(), gares.end(), d);
int pos1 = it - gares.begin();
int pos2 = it2 - gares.begin();
int pos1 = it - gares.begin(),pos2 = it2 - gares.begin();
maille.ajouterArete(pos1,pos2,i);
count++;
}
//maille.plusCourtChemin(32);
maille.affichage();
/*for(auto it:npgares){
cout << it.first << ": " << it.second << endl;
}*/
//maille.plusCourtChemin(27);
// maille.affichage();
return 0;
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment