This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_configFile.c
64 lines (53 loc) · 1.73 KB
/
create_configFile.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main(int argc,char **argv){
char * bayes[3] = {"ASK","VOR","PEL"};
int bayesCapacity[3];
int bayCapacity;
int i=1,passengers,numOfBayes=3,maxCapacity,maxPassengers,maxParkTime,numOfBuses,manuverTime;
int stattistics_Time,curent_Situation,stationManager_WorkingTime ;
srand(time(NULL));
while(i<argc){
if(!strcmp("-c",argv[i]))
maxCapacity = atoi(argv[i+1]);
else if(!strcmp("-p",argv[i]))
maxPassengers = atoi(argv[i+1]);
else if(!strcmp("-t",argv[i]))
maxParkTime = atoi(argv[i+1]);
else if(!strcmp("-b",argv[i]))
numOfBuses = atoi(argv[i+1]);
else if(!strcmp("-m",argv[i]))
manuverTime = atoi(argv[i+1]);
else if(!strcmp("-d",argv[i]))
curent_Situation= atoi(argv[i+1]);
else if(!strcmp("-st",argv[i]))
stattistics_Time = atoi(argv[i+1]);
else if(!strcmp("-wt",argv[i]))
stationManager_WorkingTime = atoi(argv[i+1]);
else{
perror("Wrong input");
exit(1);
}
i=i+2;
}
FILE * configfile = fopen("configfile.txt","w");
fprintf(configfile,"%d %d \n",numOfBayes,numOfBuses);
for(int i=0;i<numOfBayes;i++){
bayCapacity = rand()%maxCapacity + 1;
bayesCapacity[i] = bayCapacity;
fprintf(configfile,"%d ",bayCapacity);
}fprintf(configfile,"\n");
for(int i=0;i<numOfBuses;i++){
manuverTime = rand()%manuverTime + 2;
maxPassengers = rand()%maxPassengers + 5;
maxParkTime = rand()%maxParkTime + 2;
passengers = rand()%maxPassengers + 5;
fprintf(configfile,"%s %d %d %d %d\n",bayes[rand()%3],passengers,maxPassengers,maxParkTime,manuverTime);
}
fprintf(configfile,"%d %d\n",curent_Situation,stattistics_Time );
fprintf(configfile,"%d\n",stationManager_WorkingTime );
fclose(configfile);
return 0;
}