-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp_snippet.cpp
1593 lines (1318 loc) · 42.1 KB
/
cpp_snippet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**************************************
* NOMBRE: #Manuel Alejandro#
* PRIMER APELLIDO: #Garrido#
* SEGUNDO APELLIDO: #Gongora#
***************************************/
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
typedef char StringArray[500];
typedef StringArray WordsList[100];
typedef int IntegerArray[12];
typedef int IntegerArrayWeek[7];
typedef int IntegerArrayMonth[31];
typedef struct City{
StringArray cityName;
int postalCode;
};
typedef struct Connection{
City cityconnection;
int distance;
};
typedef Connection ConnectionList[200];
typedef struct RouteCalendar{
int day;
int year;
int mont;
int hour;
};
typedef City CityList [200];
typedef struct CityConnections{
City cityconnection;
Connection ConnectionList[20];
int len_connection;
bool find;
int counter;
CityList visitadas;
City start;
City end;
RouteCalendar calendar[20];
};
typedef CityConnections AllConections[200];
typedef struct CityToCity{
City start;
City end;
};
int treepL = 0;
int stop = 0;
typedef CityToCity Journeys [200];
RouteCalendar DefaultCalendar = {-1, -1, -1, -1};
Journeys AllJourneys ;
AllConections ManualJourneys ;
int lastManual = 0;
AllConections ConnectionsList;
ConnectionList path;
CityList visitadas;
CityList allCities;
StringArray bus_techo = " ______________________\n";
StringArray bus_section1 =" |,----.,----.,----.,--.\ \n";
StringArray bus_section2 =" || || || || \\ \n";
StringArray bus_section3 =" |`----'`----'|----||----\`. \n";
StringArray bus_section4 =" [";
StringArray bus_section10 ="| -||- __|(| \n";
StringArray bus_section5 =" [ ,--. |____||.--. | \n";
StringArray bus_section6 =" =-(( `))-----------(( `))== \n";
StringArray bus_section7 =" `--' `--' \n";
StringArray bus_section8 ="\n";
StringArray bus_section9 ="------------------------------------------------ Oviedo Bus Station \n";
StringArray text1 =" ______ _ _ _ _ _ \n";
StringArray text2 =" | ___ \ | | | (_) (_) | | \n";
StringArray text3 =" | |_/ /_ _ ___ _ __ | | | |_ __ _ _ ___ | | \n";
StringArray text4 =" | ___ \ | | |/ _ \ '_ \ | | | | |/ _` | |/ _ \ | | \n";
StringArray text5 =" | |_/ / |_| | __/ | | | \ \_/ / | (_| | | __/ |_| \n";
StringArray text6 =" \____/ \__,_|\___|_| |_| \___/|_|\__,_| |\___| (_) \n";
StringArray text7 =" _/ | \n";
StringArray text8 =" |__/ \n";
void draw_buen_viaje(){
printf(text1);
printf(text2);
printf(text3);
printf(text4);
printf(text5);
printf(text6);
printf(text7);
printf(text8);
}
void draw_bus(City start, City end){
StringArray target;
StringArray target2;
strncpy(target, start.cityName, 3);
strncpy(target2, end.cityName, 3);
printf(bus_techo);
printf(bus_section1);
printf(bus_section2);
printf(bus_section3);
printf(bus_section4);
printf(" ");
printf(target);
printf("-");
printf(target2);
printf(" ");
printf(bus_section10);
printf(bus_section5);
printf(bus_section6);
printf(bus_section7);
printf(bus_section8);
printf(bus_section9);
}
//Interior
City Default = {"D", 0};
City Bulnes = {"Bulnes", 33009};
City Sotres = {"Sotres", 33009};
City Tielve = {"Tielve", 33009};
City Arenos = {"Arenos", 33009};
City Carrena = {"Carrena", 33009};
City Arangas = {"Arangas", 33009};
City Rozagas = {"Rozagas", 33009};
City Ruenes = {"Ruenes", 33009};
City Avin = {"Avin", 33009};
City La_Robellada = {"La_Robellada", 33009};
//Costas
City Gijon = {"Gijon", 33009};
City Salinas = {"Salinas", 33009};
City Aviles = {"Aviles", 33009};
City Luarca = {"Luarca", 33009};
City Cudillero = {"Cudillero", 33009};
City Muros_del_Nalon = {"Muros_del_Nalon", 33009};
City San_Juan_de_la_Arena = {"Sanjuan_de_la_Arena", 33009};
City Ribadesella = {"Ribadesella", 33009};
City Soto_del_Barco = {"Soto_del_Barco", 33009};
City Rellayo = {"Rellayo", 33009};
City Aronces = {"Aronces", 33009};
//Cuenca Minera
City Oviedo = {"Oviedo", 33009};
City Olloniego = {"Olloniego", 33009};
City El_Calello = {"El_Calello", 33009};
City Las_segadas = {"Las_segadas", 33009};
City Tudela_Veguim = {"Tudela_Veguim", 33009};
City Soto_de_Rey = {"Soto_de_Rey", 33009};
City Santa_Eulalia = {"Santa_Eulalia", 33009};
City Pena_Rubia = {"Pena_Rubia", 33009};
Connection gc(City connection, int distance){
Connection response;
response.cityconnection = connection;
response.distance = distance;
return response;
}
CityToCity getCityToCityJournie(City start, City end){
CityToCity response;
response.start = start;
response.end = end;
return response;
}
CityConnections gcc(City cityconn){
CityConnections response;
response.cityconnection = cityconn;
return response;
}
int lastCity = 27;
void defineAllCities(){
allCities[0] = Oviedo;
allCities[1] = Bulnes;
allCities[2] = Sotres;
allCities[3] = Tielve;
allCities[4] = Arenos;
allCities[5] = Carrena;
allCities[6] = Arangas;
allCities[7] = Rozagas;
allCities[8] = Ruenes;
allCities[9] = Avin;
allCities[10] = La_Robellada;
allCities[11] = Salinas;
allCities[12] = Aviles;
allCities[13] = Luarca;
allCities[14] = Cudillero;
allCities[15] = Muros_del_Nalon;
allCities[16] = San_Juan_de_la_Arena;
allCities[17] = Ribadesella;
allCities[18] = Soto_del_Barco;
allCities[19] = Rellayo;
allCities[20] = Aronces;
allCities[21] = Olloniego;
allCities[22] = El_Calello;
allCities[23] = Las_segadas;
allCities[24] = Tudela_Veguim;
allCities[25] = Soto_de_Rey;
allCities[26] = Santa_Eulalia;
allCities[27] = Pena_Rubia;
}
int lastConection = 12;
void DefineDefaultCitiesConnections(){
CityConnections OviedoConnections = gcc(Oviedo);
CityConnections GijonConnections = gcc(Gijon);
CityConnections AvilesConnections = gcc(Aviles);
CityConnections CalelloConnections = gcc(El_Calello);
CityConnections SegadasConnections = gcc(Las_segadas);
CityConnections SotodeReyConnections = gcc(Soto_de_Rey);
CityConnections SantaEulaliaConnections = gcc(Santa_Eulalia);
CityConnections TudelaVeguimConnections = gcc(Tudela_Veguim);
CityConnections SalinasConnection = gcc(Salinas);
CityConnections LuarcaConnection = gcc(Luarca);
CityConnections SotoDelBarcoConnection = gcc(Soto_del_Barco);
CityConnections CudilleroConnection = gcc(Cudillero);
OviedoConnections.ConnectionList[0] = gc(Gijon, 5);
OviedoConnections.ConnectionList[1] = gc(El_Calello, 5);
OviedoConnections.ConnectionList[3] = gc(Bulnes, 5);
OviedoConnections.ConnectionList[4] = gc(Sotres, 5);
OviedoConnections.ConnectionList[5] = gc(Tielve, 5);
OviedoConnections.ConnectionList[6] = gc(Arenos, 5);
OviedoConnections.ConnectionList[7] = gc(Carrena, 5);
OviedoConnections.ConnectionList[8] = gc(Arangas, 5);
OviedoConnections.ConnectionList[9] = gc(Rozagas, 5);
OviedoConnections.ConnectionList[10] = gc(Ruenes, 5);
OviedoConnections.ConnectionList[11] = gc(Avin, 5);
OviedoConnections.ConnectionList[12] = gc(La_Robellada, 5);
GijonConnections.ConnectionList[0] = gc(Oviedo, 5);
GijonConnections.ConnectionList[1] = gc(Ribadesella, 5);
GijonConnections.ConnectionList[2] = gc(Aviles, 5);
AvilesConnections.ConnectionList[0] = gc(Gijon, 5);
AvilesConnections.ConnectionList[1] = gc(Oviedo, 5);
AvilesConnections.ConnectionList[2] = gc(Salinas, 5);
CalelloConnections.ConnectionList[0] = gc(Oviedo, 5);
CalelloConnections.ConnectionList[1] = gc(Las_segadas, 5);
SegadasConnections.ConnectionList[0] = gc(El_Calello, 5);
SegadasConnections.ConnectionList[1] = gc(Soto_de_Rey, 5);
SotodeReyConnections.ConnectionList[0] = gc(Las_segadas, 5);
SotodeReyConnections.ConnectionList[1] = gc(Santa_Eulalia, 5);
SantaEulaliaConnections.ConnectionList[0] = gc(Soto_de_Rey, 5);
SantaEulaliaConnections.ConnectionList[1] = gc(Tudela_Veguim, 5);
TudelaVeguimConnections.ConnectionList[0] = gc(Santa_Eulalia, 5);
TudelaVeguimConnections.ConnectionList[1] = gc(Pena_Rubia, 5);
SalinasConnection.ConnectionList[0] = gc(Oviedo, 5);
SalinasConnection.ConnectionList[1] = gc(Cudillero, 15);
CudilleroConnection.ConnectionList[0] = gc(Salinas, 15);
CudilleroConnection.ConnectionList[1] = gc(Luarca, 5);
LuarcaConnection.ConnectionList[0] = gc(Cudillero, 5);
LuarcaConnection.ConnectionList[1] = gc(Soto_del_Barco, 5);
SotoDelBarcoConnection.ConnectionList[0] = gc(Luarca, 5);
SotoDelBarcoConnection.ConnectionList[1] = gc(Muros_del_Nalon, 5);
ConnectionsList[0] = OviedoConnections;
ConnectionsList[1] = GijonConnections;
ConnectionsList[2] = CalelloConnections;
ConnectionsList[3] = SegadasConnections;
ConnectionsList[4] = SotodeReyConnections;
ConnectionsList[5] = SantaEulaliaConnections;
ConnectionsList[6] = TudelaVeguimConnections;
ConnectionsList[7] = AvilesConnections;
ConnectionsList[8] = SalinasConnection;
ConnectionsList[9] = CudilleroConnection;
ConnectionsList[10] = LuarcaConnection;
ConnectionsList[11] = SotoDelBarcoConnection;
}
void DefineDefaultConections(){
DefineDefaultCitiesConnections();
}
CityConnections findRoute(City partida, City destino, int counter){
CityConnections finalRoute;
CityConnections result;
bool is = false;
finalRoute.find = false;
for(int i = 0; i<200; i++){
if(strlen(ConnectionsList[i].cityconnection.cityName) > 0 && strcmp(ConnectionsList[i].cityconnection.cityName, partida.cityName) == 0 ){
for(int x = 0; x<20; x++){
is = false;
if(strlen(ConnectionsList[i].ConnectionList[x].cityconnection.cityName) > 0){
for(int y = 0; y<200; y++){
if(strlen(visitadas[y].cityName) > 1 && strcmp(visitadas[y].cityName, ConnectionsList[i].ConnectionList[x].cityconnection.cityName) == 0){
is = true;
}
}
if(strcmp(ConnectionsList[i].ConnectionList[x].cityconnection.cityName, destino.cityName) == 0){
counter ++;
finalRoute.ConnectionList[counter] = ConnectionsList[i].ConnectionList[x];
path[counter] = ConnectionsList[i].ConnectionList[x];
finalRoute.len_connection = counter;
finalRoute.find = true;
finalRoute.start = partida;
finalRoute.end = destino;
return finalRoute;
}
if(!is){
counter ++;
visitadas[counter] = ConnectionsList[i].ConnectionList[x].cityconnection;
finalRoute.visitadas[counter] = ConnectionsList[i].ConnectionList[x].cityconnection;
result = findRoute(ConnectionsList[i].ConnectionList[x].cityconnection, destino, counter);
for(int c = counter; c<(result.counter - counter); c++){
visitadas[c] = result.visitadas[c];
}
if(result.find){
finalRoute.find = true;
finalRoute.ConnectionList[counter] = ConnectionsList[i].ConnectionList[x];
path[counter] = ConnectionsList[i].ConnectionList[x];
finalRoute.start = partida;
finalRoute.end = destino;
return finalRoute;
}
counter = counter + (result.counter - counter);
}
}
}
}
}
visitadas[counter] = partida;
finalRoute.visitadas[counter] = partida;
finalRoute.counter = counter;
finalRoute.start = partida;
finalRoute.end = destino;
return finalRoute;
}
void DefineDefaultJourneys (){
AllJourneys [0] = getCityToCityJournie(Oviedo, Gijon);
AllJourneys [1] = getCityToCityJournie(Oviedo, Aviles);
AllJourneys [2] = getCityToCityJournie(Oviedo, Soto_de_Rey);
AllJourneys [3] = getCityToCityJournie(Oviedo, Santa_Eulalia);
AllJourneys [4] = getCityToCityJournie(Oviedo, Salinas);
AllJourneys [5] = getCityToCityJournie(Oviedo, Ribadesella);
AllJourneys [6] = getCityToCityJournie(Oviedo, Cudillero);
AllJourneys [7] = getCityToCityJournie(Oviedo, Luarca);
AllJourneys [8] = getCityToCityJournie(Oviedo, Tudela_Veguim);
AllJourneys [9] = getCityToCityJournie(Oviedo, Las_segadas);
AllJourneys [10] = getCityToCityJournie(Oviedo, Bulnes);
AllJourneys [11] = getCityToCityJournie(Oviedo, Sotres);
AllJourneys [12] = getCityToCityJournie(Oviedo, Tielve);
AllJourneys [13] = getCityToCityJournie(Oviedo, Arenos);
AllJourneys [14] = getCityToCityJournie(Oviedo, Carrena);
AllJourneys [15] = getCityToCityJournie(Oviedo, Arangas);
AllJourneys [16] = getCityToCityJournie(Oviedo, Rozagas);
AllJourneys [17] = getCityToCityJournie(Oviedo, Ruenes);
AllJourneys [18] = getCityToCityJournie(Oviedo, Avin);
AllJourneys [19] = getCityToCityJournie(Oviedo, La_Robellada);
AllJourneys [20] = getCityToCityJournie(Oviedo, El_Calello);
}
void MakeRute(City start, City end){
CityConnections rute;
treepL = 0;
stop = 0;
for(int i = 0; i<200; i++){ visitadas[i] = Default; path[i].cityconnection = Default; }
visitadas[0] = start;
rute = findRoute(start, end, 0);
draw_bus(rute.start, rute.end);
printf("Importante: Las rutas Automaticas se efectian diariamente.");
printf("\n");
printf("Partida: ");
printf(start.cityName);
printf("\n");
printf("Destino: ");
printf(end.cityName);
printf("\n");
printf("El Bus efectua paradas en:");
for(int x = 0; x < 200; x++){
if(strlen(path[x].cityconnection.cityName) > 1){
stop ++;
printf("\n");
printf("%d - ", stop);
printf(path[x].cityconnection.cityName);
treepL = treepL + path[x].distance;
printf("\n");
}
};
printf("\n");
printf("La distancia es:");
printf(" ");
printf("%d km", treepL);
printf("\n");
printf("El precio final es:");
printf(" ");
printf("%.2f $", treepL * 0.2);
printf("\n");
printf("BUEN VIAJE!!");
printf("\n");
}
void MakeRutemanualy(CityConnections rute){
printf("Partida: ");
printf(rute.start.cityName);
printf("\n");
printf("Destino: ");
printf(rute.end.cityName);
printf("\n");
printf("El Bus efectua paradas en:");
for(int x = 0; x < 200; x++){
if(strlen(rute.ConnectionList[x].cityconnection.cityName) > 1){
stop ++;
printf("\n");
printf("%d - ", stop);
printf(rute.ConnectionList[x].cityconnection.cityName);
treepL = treepL + rute.ConnectionList[x].distance;
printf("\n");
}
};
printf("\n");
printf("La distancia es:");
printf(" ");
printf("%d km", treepL);
printf("\n");
printf("En las fechas:");
printf(" ");
for(int x = 0; x < 20; x++){
if(rute.calendar[x].day > 0){
printf("\n");
printf("El dia %d del mes %d del año %d a la hora %d", rute.calendar[x].day, rute.calendar[x].mont, rute.calendar[x].year, rute.calendar[x].hour);
printf("\n");
}
}
printf("\n");
printf("\n");
}
void MakeRutemanualyFinal(CityConnections rute){
draw_bus(rute.start, rute.end);
printf("Partida: ");
printf(rute.start.cityName);
printf("\n");
printf("Destino: ");
printf(rute.end.cityName);
printf("\n");
printf("El Bus efectua paradas en:");
for(int x = 0; x < 200; x++){
if(strlen(rute.ConnectionList[x].cityconnection.cityName) > 1){
stop ++;
printf("\n");
printf("%d - ", stop);
printf(rute.ConnectionList[x].cityconnection.cityName);
treepL = treepL + rute.ConnectionList[x].distance;
printf("\n");
}
};
printf("\n");
printf("La distancia es:");
printf(" ");
printf("%d km", treepL);
printf("\n");
printf("El precio final es:");
printf(" ");
printf("%.2f $", treepL * 0.2);
printf("\n");
printf("BUEN VIAJE!!");
printf("\n");
}
void ShowAllJourneys (){
for(int i = 0; i<200; i++){
if(strlen(AllJourneys [i].start.cityName) > 1){
MakeRute(AllJourneys [i].start, AllJourneys [i].end);
}
}
}
void VisualiceRouteAutomaticaly(){
int option;
system("cls");
printf("\n");
printf("Rutas Automaticas Activas.");
for(int i = 0; i<200; i++){
if(strlen(AllJourneys [i].start.cityName) > 1){
printf("\n");
printf("%d ", i);
printf("Desde: ");
printf(AllJourneys [i].start.cityName);
printf(" ");
printf("Hasta: ");
printf(AllJourneys [i].end.cityName);
}
}
printf("\n");
printf("Teclear el numero de a lruta que desea visualizar?");
printf("\n");
printf("\n");
scanf("%d", &option);
system("cls");
MakeRute(AllJourneys [option].start, AllJourneys [option].end);
printf("Teclear cualquier numero para continuar");
printf("\n");
scanf("%d", &option);
}
void VisualiceRouteManual(){
int option;
system("cls");
printf("\n");
printf("Rutas Automaticas Activas.");
for(int i = 0; i<200; i++){
if(strlen(ManualJourneys [i].start.cityName) > 1){
printf("\n");
printf("%d ", i);
printf("Desde: ");
printf(ManualJourneys [i].start.cityName);
printf(" ");
printf("Hasta: ");
printf(ManualJourneys [i].end.cityName);
}
}
printf("\n");
printf("Teclear el numero de la ruta que desea visualizar?");
printf("\n");
printf("\n");
scanf("%d", &option);
system("cls");
MakeRutemanualyFinal(ManualJourneys [option]);
printf("Teclear cualquier numero para continuar");
printf("\n");
scanf("%d", &option);
}
void VisualiceRoute(){
int option;
system("cls");
printf("\n");
printf(" Ver Rutas Automaticas: (Pulse 1)");
printf("\n");
printf(" Ver Rutas Manuales: (Pulse 2)");
printf("\n");
printf(" Volver: (Pulse 3)");
printf("\n");
printf("\n");
scanf("%d", &option);
switch(option){
case 1:
system("cls");
VisualiceRouteAutomaticaly();
break;
case 2:
system("cls");
VisualiceRouteManual();
break;
case 3:
break;
}
}
int lasStep = 0;
CityConnections addStepsManualy(CityConnections newRoute){
int option;
system("cls");
printf("\n");
printf("\n");
printf("Lista de ciudades actualmente en el sistema.");
printf("\n");
for(int i = 0; i<200; i++){
if(strlen(allCities[i].cityName) > 1){
printf("\n");
printf("%d ", i);
printf(allCities[i].cityName);
}
}
printf("\n");
printf("Teclear el numero de la ciudad de parada.");
printf("\n");
scanf("%d", &option);
newRoute.ConnectionList[lasStep] = gc(allCities[option], 5);
lasStep++;
printf("\n");
printf("Quiere añadir otra parada ? Pulse(1)");
printf("\n");
printf("Quiere Continuar ? Pulse(2)");
printf("\n");
scanf("%d", &option);
switch(option){
case 1:
system("cls");
newRoute = addStepsManualy(newRoute);
break;
}
return newRoute;
}
void CreateRouteMannual(){
int option;
int day;
int year;
int mont;
int hour;
CityConnections newRoute;
for(int x = 0; x < 200; x++){
newRoute.ConnectionList[x].cityconnection = Default;
};
for(int x = 0; x < 20; x++){
newRoute.calendar[x] = DefaultCalendar;
};
system("cls");
printf("\n");
printf("\n");
printf("Lista de ciudades actualmente en el sistema.");
printf("\n");
for(int i = 0; i<200; i++){
if(strlen(allCities[i].cityName) > 1){
printf("\n");
printf("%d ", i);
printf(allCities[i].cityName);
}
}
printf("\n");
printf("Teclear el numero de la ciudad de destino.");
printf("\n");
scanf("%d", &option);
newRoute.start = Oviedo;
newRoute.end = allCities[option];
lasStep = 0;
newRoute = addStepsManualy(newRoute);
ManualJourneys [lastManual] = newRoute;
lastManual++;
}
void saveRouteAutomaticaly(City to){
bool exist;
int option;
int counter = 0;
exist = false;
system("cls");
printf("\n");
printf("Estamos procesando su peticion.");
printf("\n");
for(int i = 0; i<200; i++){
if(strlen(AllJourneys [i].start.cityName) > 1){
counter++;
if(strcmp(to.cityName, AllJourneys [i].end.cityName) == 0){
exist = true;
}
}
}
if(!exist){
AllJourneys [counter] = getCityToCityJournie(Oviedo, to);
}
else{
printf("\n");
printf("El viaje ya existe.");
}
printf("\n");
printf("Teclear cualquier numero para volver.");
printf("\n");
scanf("%d", &option);
}
void CreateRouteAutomaticaly(){
int option;
system("cls");
printf("\n");
printf("Lista de ciudades actualmente en el sistema.");
printf("\n");
for(int i = 0; i<200; i++){
if(strlen(allCities[i].cityName) > 1){
printf("\n");
printf("%d ", i);
printf(allCities[i].cityName);
}
}
printf("\n");
printf("Teclear el numero de la ciudad a la que quiere ir.");
printf("\n");
scanf("%d", &option);
saveRouteAutomaticaly(allCities[option]);
}
void CreateRoute(){
int option;
system("cls");
printf("\n");
printf("Puede crear una ruta manualmente o dejar que el sistema lo haga por usted.");
printf("\n");
printf(" Crear ruta Manualmente: (Pulse 1)");
printf("\n");
printf(" Crear ruta Automaticamente: (Pulse 2)");
printf("\n");
printf(" Volver: (Pulse 3)");
printf("\n");
printf("\n");
scanf("%d", &option);
switch(option){
case 1:
system("cls");
CreateRouteMannual();
CreateRoute();
break;
case 2:
system("cls");
CreateRouteAutomaticaly();
CreateRoute();
break;
case 3:
break;
}
}
void EditRoute(){
int option;
system("cls");
printf("\n");
printf("Gestion de Rutas");
printf("\n");
printf(" Crear ruta: (Pulse 1)");
printf("\n");
printf(" Volver: (Pulse 3)");
printf("\n");
printf("Teclear una opcion valida (1|2|3)?");
printf("\n");
scanf("%d", &option);
switch(option){
case 1:
system("cls");
CreateRoute();
EditRoute();
break;
case 3:
break;
}
}
int dayofweek(int d, int m, int y)
{
IntegerArray t = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
y = y - (m < 3);
return ( y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
void drawCalendar(int m, int ye, IntegerArrayMonth days){
int monthL = 0;
bool f = false;
bool is = false;
IntegerArrayWeek weekdays = {0,1,2,3,4,5,6};
int weekCounter = 0;
switch(m){
case 2:
monthL = 28;
break;
case 4:
monthL = 30;
break;
case 6:
monthL = 30;
break;
case 9:
monthL = 30;
break;
case 11:
monthL = 30;
break;
default:
monthL = 31;
}
printf("| L | M | M | J | V | S | D |");
printf("\n");
for(int x = 0; x < monthL; x++){
is = false;
for(int y = 0; y<7; y++){
if(weekdays[y] == dayofweek(x, m, ye)){
f = true;
for(int z = 0; z < 31; z++){
if(days[z] == x){
is = true;
}
}
if(x < 10 && is){
printf(" 0%d ", x);
}
else if(is){
printf(" %d ", x);
}
if(!is){
printf(" ** ");
}
}
if(!f){
printf(" -- ");
weekCounter++;
}
}
weekCounter++;
if(weekCounter == 7){
printf("\n");
weekCounter = 0;
}
}
}
void ProgrameCalendarRoute(){
system("cls");
printf("\n");
printf("ProgrameCalendarRoute");
}
void RouteRouteCalendarData(){
system("cls");
printf("\n");
printf("RouteRouteCalendarData");
}
void MonthCalendarTreep(){
CityConnections rute;
int option1 = 0;
int option2 = 0;
int month = 0;
int year = 0;
IntegerArrayMonth days;
system("cls");
printf("\n");
printf("Lista de ciudades actualmente en el sistema.");
printf("\n");
for(int i = 0; i<200; i++){
if(strlen(allCities[i].cityName) > 1){
printf("\n");
printf("%d ", i);
printf(allCities[i].cityName);
}
}
printf("\n");
printf("Teclear el numero de la ciudad destino.");
printf("\n");
scanf("%d", &option2);
for(int x = 0; x<200; x++){
if(strcmp(ManualJourneys [x].end.cityName, allCities[option2].cityName) == 0){
rute = ManualJourneys [x];
}
}
printf("Teclear el mes.");
printf("\n");
scanf("%d", &month);
printf("Teclear el año.");
printf("\n");
scanf("%d", &year);
for(int x = 0; x<200; x++){
if(rute.calendar[x].day > 0 && rute.calendar[x].mont == month){
days[rute.calendar[x].day] = rute.calendar[x].day;
}
}
system("cls");
drawCalendar(month,year,days);
printf("\n");
printf("Teclear cualquier numero para continuar.");
printf("\n");
scanf("%d", &option2);
}
void TreepInformation(){
CityConnections rute;
int option1 = 0;
int option2 = 0;
int month = 0;
int year = 0;
IntegerArrayMonth days;
system("cls");