There is a parking area in a department you are required to park cars. Motor cycles and bicycles in their respective parking area. What data structure is suitable for this. Write code to park each vehicle. (Hint: All spaces are null at beginning and search empty space to park.)
#include<iostream.h>
int main(){
int rs[10],hours[10],cars[10];
for(int i=1;i<=10;++i){
cout<<"Enter number car number"<<endl;
cin>>cars[i];
cout<<"Enter parking hours"<<endl;
cin>>hours[i];
if(hours[i]<=3){
rs[i]=30;
cout<<rs[i]<<endl;
}
if(hours[i]>3 && hours[i]<24){
rs[i]=30+(hours[i]-3)*5;
cout<<rs[i]<<endl;
}
if(hours[i]==24){
rs[i]=80;
cout<<rs[i]<<endl;
}
}
return 0
Comments
Leave a comment