int main() { std::array<std::string,3> fileName = {"cities_3.data", "cities_10.data", "cities_50.data"}; std::array<std::string,3> filePathDistance = {"shortest_3_DKT.txt", "shortest_10_DKT.txt", "shortest_50_DKT.txt"}; for (int i = 0; i < fileName.size(); i++) { int nodes = lines_count(fileName[i]); //distance matrix std::vector<std::vector<int>> d = input2vector(fileName[i]); std::ofstream fileOut1; fileOut1.open(filePathDistance[i]); std::ofstream fileOut2; fileOut2.open("timer_DKT.txt", std::ios_base::app); std::chrono::time_point<std::chrono::system_clock> start, end; start = std::chrono::system_clock::now(); for (int i = 1; i <= nodes; i++){ for (int j = i+1; j <= nodes; j++){ int infinity = 1234567;//know from the input file //set all to infinity std::vector<City> city(nodes,City(infinity,false,0)); int shortest = Dijkstra(nodes,i,j,city,d); path_recon_to_file(fileOut1, i, j, nodes, city); fileOut1 << "\t\t" << shortest; fileOut1 << std::endl; } } end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end-start; fileOut2 << std::fixed << std::setprecision(0)<< fileName[i] << "\t";//fix precision fileOut2 << std::fixed << std::setprecision(14)<<elapsed_seconds.count(); fileOut2 << std::endl; std::cout << "elapsed time to find shortest route with Dijkstra for " << fileName[i] << " is: " << std::fixed << std::setprecision(14)<<elapsed_seconds.count() << " seconds" << std::endl; } }
std::vector<_TReal> GenerateCity(_TRandom &random, const std::vector<std::pair<_TReal, _TReal> > &boundary) { std::vector<_TReal> city(boundary.size()); for (size_t i = 0; i < city.size(); ++i) { std::uniform_real_distribution<_TReal> dist(boundary[i].first, boundary[i].second); city[i] = dist(random); } return city; }
// TEST THE CITY CONSTRUCTOR TEST_F(CityTest, Constructor){ std::ofstream stream("Output files/unusedOutput.txt"); City city("XML-Files/stad.xml", stream, "empty", false, false); EXPECT_TRUE(city.properlyInitialized()); EXPECT_EQ(50, city.getAmountHouses()); EXPECT_EQ(1, city.getAmountDepartments()); EXPECT_EQ(8, city.getAmountStreets()); EXPECT_EQ(16, city.getAmountCrossroads()); EXPECT_EQ(2, city.getAmountTrucks()); stream.close(); }
int main(void) { FILE *file; int switchRun; int endRequested = 0; struct person *list = NULL; file = fopen(FILENAME, "r"); if (file == NULL) { perror("Cant read file"); return 1; } list = loadFromFile(file); printf("- LOADED ---------------------\n"); printPersons(list); while (endRequested == 0) { printf("- MENU ---------------------\n"); printf("[1] - addPerson\n"); printf("[2] - deletePerson\n"); printf("[3] - age\n"); printf("[4] - city == 'Presov'\n"); printf("other - close\n"); scanf("%d", &switchRun); switch (switchRun) { case 1 : list = addPerson(list); break; case 2 : list = delPerson(list); break; case 3 : age(list); break; case 4 : city(list, "Presov"); break; default: endRequested = 1; } } freeItems(list); return 0; }
DllExport void DLLPublishToPython() { CyEnumsPythonInterface(); CyGamePythonInterface(); CyRandomPythonInterface(); CyTeamPythonInterface(); CyAreaPythonInterface(); CyStructsPythonInterface1(); CyMapPythonInterface(); CyMapGeneratorPythonInterface(); CySelectionGroupInterface(); CyArtFileMgrPythonInterface(); CyGameTextMgrInterface(); CyInfoPythonInterface1(); CyInfoPythonInterface2(); CyInfoPythonInterface3(); CyHallOfFameInterface(); CyGameCoreUtilsPythonInterface(); CyMessageControlInterface(); // // large interfaces which can be split across files if need be // python::class_<CyCity> city ("CyCity"); // define city class CyCityPythonInterface1(city); // publish it's methods python::class_<CyPlayer> player ("CyPlayer"); // define player class CyPlayerPythonInterface1(player); // publish it's methods CyPlayerPythonInterface2(player); // publish it's methods python::class_<CyUnit> unit ("CyUnit"); // define unit class CyUnitPythonInterface1(unit); // publish it's methods python::class_<CyPlot> plot ("CyPlot"); // define plot class CyPlotPythonInterface1(plot); // publish it's methods python::class_<CyGlobalContext> gc ("CyGlobalContext"); // define globals class CyGlobalContextPythonInterface1(gc); // publish it's methods CyGlobalContextPythonInterface2(gc); // publish it's methods CyGlobalContextPythonInterface3(gc); // publish it's methods CyGlobalContextPythonInterface4(gc); // publish it's methods }
int WeatherModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { typedef bb::cascades::GroupDataModel QMocSuperClass; _id = QMocSuperClass::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 3) qt_static_metacall(this, _c, _id, _a); _id -= 3; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = city(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setCity(*reinterpret_cast< QString*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
void editDialog::set_data(int item_i) { QString s_start, s_stop; this->item = item_i; base_pol pol("pol.txt"); pol.load_data(); polaczenie at = pol.get_item(item_i); base_city city("city.txt"); city.load_data(); s_start = city.find_name(at.get_start()); s_stop = city.find_name(at.get_stop()); a_time->Edit->setText(QString::number(at.get_a_time())); b_time->Edit->setText(QString::number(at.get_b_time())); cost->Edit->setText(QString::number(at.get_cost())); op->Edit->setText(at.get_op()); from->Edit->setText(s_start); to->Edit->setText(s_stop); }
void editDialog::add() { // Zmienne poczatkowe QString s_start, s_stop; int from_n, to_n, typ; //Wczytanie danych if(samochod->isChecked()) typ=0; if(pociag->isChecked()) typ=1; if(samolot->isChecked()) typ=2; if(autobus->isChecked()) typ=4; s_start = from->Edit->text(); s_stop = to->Edit->text(); from_n =0; to_n=0; //odczyt bazy miast i znalezienie/dodanie rekordu base_city city("city.txt"); city.load_data(); from_n = city.insert(s_start); to_n = city.insert(s_stop); city.save_data(); //Tworzenie obiektu polaczenie // polaczenie *p; // p = new p_bus(from, to, cost, a_time, b_time, op, typ); polaczenie p(from_n, to_n, cost->get_value(), a_time->get_value(), b_time->get_value(), op->get_value(), typ); //polaczenie(from, to, cost, a_time, b_time, op, typ); //Zapisanie obiektu base_pol pol("pol.txt"); pol.load_data(); pol.del(item); pol.insert(p); pol.save_data(); emit end(); this->close(); }
void addDialog::add() { polaczenie p; QString s_start = fromLine->text(); QString s_stop = toLine->text(); QFile city("city.txt"); if(!city.open(QIODevice::ReadOnly)) { QMessageBox::critical(this, tr("Error"), tr("Problem z otwarciem pliku miast")); } QDataStream in(&city); in.setVersion(QDataStream::Qt_4_1); QMap<QString, int> city_map; in >> city_map; city.close(); QFile pol("pol.txt"); if(!pol.open(QIODevice::ReadOnly)) { QMessageBox::critical(this, tr("Error"), tr("Problem z otwarciem pliku miast")); } in.setDevice(&pol); in.setVersion(QDataStream::Qt_4_1); QVector<polaczenie> pol_vector; in >> pol_vector; // QMessageBox::critical(this, tr("Error"), QString::number(city_map.count())); pol.close(); int c =city_map.count(); int from =0; int to=0; if(c!=0) { if(city_map.contains(s_start)) from = city_map[s_start]; if(city_map.contains(s_stop)) to = city_map[s_stop]; if(from==0) { city_map.insert(s_start, city_map.count()+1); from = city_map.count()+1; } if(to==0) { city_map.insert(s_stop, city_map.count()+1); to = city_map.count()+1; } } else { city_map.insert(s_start, c+1); city_map.insert(s_stop, c+2); } if(!city.open(QIODevice::WriteOnly)) { QMessageBox::critical(this, tr("Error"), tr("Problem z otwarciem pliku miast")); } QDataStream out(&city); out.setVersion(QDataStream::Qt_4_1); out << city_map; out << "sdfgsdfgsd"; QMessageBox::critical(this, tr("Error"), QString::number(city_map.count())); city.close(); p.set_a_time(atimeLine->text().toInt()); p.set_b_time(btimeLine->text().toInt()); p.set_cost(costLine->text().toInt()); p.set_op(opLine->text()); p.set_start(from); p.set_stop(to); if(samochod->isChecked()) p.set_type(0); if(pociag->isChecked()) p.set_type(1); if(samolot->isChecked()) p.set_type(2); if(autobus->isChecked()) p.set_type(3); if(!pol.open(QIODevice::WriteOnly)) { QMessageBox::critical(this, tr("Error"), tr("Problem z otwrciem pliku połączeń")); } out.setDevice(&pol); out.setVersion(QDataStream::Qt_4_1); pol_vector.append(p); out << pol_vector; this->close(); }
void main(){ int gdriver = EGA, gmode = EGAHI, errorcode; initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); bk(); travel(); gravitas(); tvar=0; m1c=m2c=adc=chdc=0; signup_traction(); while(ch!=27) { if(kbhit()) { ch=getch(); if(ch==77) {way(1);} if(ch==75) {way(0);} if(ch==80) {menu1();setcolor(6);settextstyle(2,0,4); outtextxy(68,180,"<-");break;} }} flag1: city(); m1c=0; while(ch!=27) { gravitas(); if(kbhit()) { ch=getch(); if(ch==80 && m1c<=15) //i city {menu1();city();++m1c;ibar();tarrow(m1c);mcounter(m1c);} if(ch==72 && m1c>=1 && m1c<=15) {menu1();city();m1c--;ibar();tarrow(m1c);mcounter(m1c);} if(ch==80 && m1c>=16 && m1c<=33) //2 city {menu1();city2();m1c++;ibar();tarrow(m1c);mcounter(m1c);} if(ch==72 && m1c>=16 && m1c<=33) {menu1();city2();m1c--;ibar();tarrow(m1c);mcounter(m1c);} if(ch==80 && m1c>=34 && m1c<=51) //3 city {menu1();city3();m1c++;ibar();tarrow(m1c);mcounter(m1c);} if(ch==72 && m1c>=34 && m1c<=51) {menu1();city3();m1c--;ibar();tarrow(m1c);mcounter(m1c);} if(ch==80 && m1c>=52 && m1c<56) //4 city {menu1();city4();m1c++;ibar();tarrow(m1c);mcounter(m1c);} if(ch==72 && m1c>=52 && m1c<=56) {menu1();city4();m1c--;ibar();tarrow(m1c);mcounter(m1c);} if(ch==13) {from=m1c; bk(); travel(); mcounter(m1c);from=m1c;if(tvar)tmcounter(m2c);break;} if(ch==77) { bk();travel();menu2();tcity();mcounter(m1c);from=m1c;menu2();break;} }} //flag2: m2c=0; while(ch!=27) { gravitas(); if(kbhit()) { ch=getch(); if(ch==80 && m2c<=15) //i city {menu2();tcity();++m2c;tbar();arrow(m2c);tmcounter(m2c);} if(ch==72 && m2c>=1 && m2c<=15) {menu2();tcity();m2c--;tbar();arrow(m2c);tmcounter(m2c);} if(ch==80 && m2c>=16 && m2c<=33) //2 city {menu2();tcity2();m2c++;tbar();arrow(m2c);tmcounter(m2c);} if(ch==72 && m2c>=16 && m2c<=33) {menu2();tcity2();m2c--;tbar();arrow(m2c);tmcounter(m2c);} if(ch==80 && m2c>=34 && m2c<=51) //3 city {menu2();tcity3();m2c++;tbar();arrow(m2c);tmcounter(m2c);} if(ch==72 && m2c>=34 && m2c<=51) {menu2();tcity3();m2c--;tbar();arrow(m2c);tmcounter(m2c);} if(ch==80 && m2c>=52 && m2c<56) //4 city {menu2();tcity4();m2c++;tbar();arrow(m2c);tmcounter(m2c);} if(ch==72 && m2c>=52 && m2c<=56) {menu2();tcity4();m2c--;tbar();arrow(m2c);tmcounter(m2c);} if(ch==13) {to=m2c; bk(); travel(); tvar=1;tmcounter(m2c);to=m2c;mcounter(m1c);break;} if(ch==75) {bk();travel(); to =m2c; tvar=1; tmcounter(m2c);to=m2c;menu1(); //goto flag1; break;} } } while(ch!=27) { gravitas(); if(kbhit()) { ch=getch(); if(ch==80 && adc<10) {admenu();adult(); adc++; adarrow(adc); adcounter(adc);} if(ch==72 && adc>0) {admenu();adult(); adc--; adarrow(adc);adcounter(adc);} if(ch==77) {adno=adc;chmenu();bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);break;} if(ch==13) {adno=adc;bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);break;} }} while(ch!=27) { gravitas(); if(kbhit()) { ch=getch(); if(ch==80 && chdc<10) {chmenu();child(); chdc++; charrow(chdc); chcounter(chdc);} if(ch==72 && chdc>0) {chmenu();child(); chdc--; charrow(chdc);chcounter(chdc);} if(ch==77) {chno=chdc;chmenu();bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc); break;} if(ch==13) {chno=chdc;bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc); break;} }} while(ch!=27) { gravitas(); if(kbhit()) { ch=getch(); if(ch==80 && inc<10) {inmenu();infant(); inc++; inarrow(inc); incounter(inc);} if(ch==72 && inc>0) {inmenu();infant(); inc--; inarrow(inc);incounter(inc);} if(ch==77) {inno=inc;inmenu();bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc);incounter(inc); break;} if(ch==13) {inno=chdc;bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc);incounter(inc); break;} }} while(ch!=27) { gravitas(); if(kbhit()) { ch=getch(); if(ch==77) {ecob(1);suit=1;} if(ch==75) {ecob(0);suit=0;} if(ch==13) {break;} } } setcolor(1);settextstyle(2,0,4); ch=0; while(ch!=13) { if(kbhit()) {da+=8; ch=getch(); if(isalnum(ch) && da<=95) {sprintf(dater,"%c",ch); outtextxy(da,272,dater);} if(ch==8 && da>=45 && da<=180) {da=da-8; setfillstyle(1,15); bar(da,272,da+8,285); da=da-8;} }} if(suit==0)flight(to); if(suit==1)bflight(to); traction(); secure(); money_transfer(); getch(); closegraph();}