Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // zmiana całej funkcji w funkcje.cpp:
- void odlegwsp(stacja *&start)
- {
- stacja*t=start;
- double min;
- double pierw;
- double a, b;
- string a1, b1;
- double a1_num, b1_num;
- string najbl_dziel;
- string najbl_nazwa;
- string najbl_szer;
- string najbl_dl;
- cout<<endl<<"Podaj szerokosc geograficzna"<<endl;
- cin>>a;
- cout<<endl<<"Podaj dlugosc geograficzna"<<endl;
- cin>>b;
- //inicjacja wartości minimalnej
- a1=t->wsp1;
- b1=t->wsp2;
- a1_num = strtod(a1.c_str(),NULL);
- b1_num = strtod(b1.c_str(),NULL);
- min = sqrt((a-a1_num)*(a-a1_num)+(b-b1_num)*(b-b1_num));
- while(t)
- {
- a1=t->wsp1;
- b1=t->wsp2;
- a1_num = strtod(a1.c_str(),NULL);
- b1_num = strtod(b1.c_str(),NULL);
- pierw = sqrt((a-a1_num)*(a-a1_num)+(b-b1_num)*(b-b1_num));
- if(pierw <= min){
- min=pierw;
- najbl_dziel = t->dziel;
- najbl_nazwa = t->nazwa;
- najbl_szer = a1;
- najbl_dl = b1;
- }
- t=t->next;
- }
- cout << endl << "Najbliższa stacja:" << endl;
- cout << najbl_dziel << endl;
- cout << najbl_nazwa << endl;
- cout << najbl_szer << endl;
- cout << najbl_dl << endl;
- }
- //zmiana typu w pliku funkcje.h
- zamiast
- double odlegwsp(stacja *&start);
- robisz
- void odlegwsp(stacja *&start);
- //w main nic nie zmieniasz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement