U E D R , A S I H C RSS

Bus Simulation/영동

.

...
  • 히 할 . . . -

~cpp 
#include<iostream.h>
#define road 300 // 회하 300킬.  5 .


class Bus// 60km/h--> 1km/m 함.
{
public:
	int bus_loc;// 
	//  
	//     2 .
	void move(int x_min);	
	//  
	void show(int a);
};

void Bus::move(int x_min)
{
	for(;;)
	{
		if(x_min<=30){
			bus_loc=bus_loc+x_min;// 1킬  x   x킬 
			x_min=0;//0 화.     .
			break;
		}
		if(x_min>30){
			x_min=x_min-30;
			bus_loc=bus_loc+30;
		}
		if(30<bus_loc&&bus_loc<=60)
			bus_loc=bus_loc-2;
		else if(60<bus_loc&&bus_loc<=90)
			bus_loc=bus_loc-4;
		else if(90<bus_loc&&bus_loc<=120)
			bus_loc=bus_loc-6;
		else if(120<bus_loc&&bus_loc<=150)
			bus_loc=bus_loc-8;
		else if(150<bus_loc&&bus_loc<=180)
			bus_loc=bus_loc-10;
		else if(180<bus_loc&&bus_loc<=210)
			bus_loc=bus_loc-12;
		else if(240<bus_loc&&bus_loc<=270)
			bus_loc=bus_loc-14;
		else if(270<bus_loc&&bus_loc<=300)
			bus_loc=bus_loc-16;

		if(bus_loc>road){//300킬   
			bus_loc=bus_loc-road;
		}
	}
	
}


void Bus::show(int a)
{
	if(bus_loc>0){	
		cout<<a+1<<"    "<<bus_loc<<"km"<<endl;
	}
	else
		cout<<a+1<<"    ."<<endl;
}	

void main()
{
	int time=0;
	int i;
	cout<<"===============Bus Simulation=================="<<endl;
	cout<<"   ?";
	cin>>time;
	Bus bus[10];// 10 
	bus[0].bus_loc=0;//10  
	bus[1].bus_loc=-10;
	bus[2].bus_loc=-20;
	bus[3].bus_loc=-30;
	bus[4].bus_loc=-40;
	bus[5].bus_loc=-50;
	bus[6].bus_loc=-60;
	bus[7].bus_loc=-70;
	bus[8].bus_loc=-80;
	bus[9].bus_loc=-90;
	for(i=0;i<10;i++)
	{
		bus[i].move(time);

	}
	cout<<"____________Result of Bus Simulation___________"<<endl;
	for(i=0;i<10;i++)
		bus[i].show(i);
}


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:39
Processing time 0.0122 sec