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
|
#include <stdio.h>
#define Timeslots 5
#define Maxbus 3
void main(void)
{
int j,k,i,Longesttimetoreachhome,currenttotaltime;
int bustransittime[Maxbus][Timeslots] = {
{10, 10, 10, 10, 10} ,
{40, 20, 30, 30, 50} ,
{35, 25, 32, 34, 36}
};
int busstopwaitingtime[5]={5,5,5,5,5};
currenttotaltime=0;
Longesttimetoreachhome=0;
{
for (j=0; j<5; j++)
{
for (k=0; k<3; k++)
{
for(i=0;i<1;i++)
currenttotaltime=bustransittime[k][j]+busstopwaitingtime[j];
if ( Longesttimetoreachhome < currenttotaltime )
Longesttimetoreachhome=currenttotaltime;
}
} printf("Longest time to reach home is %d\n",Longesttimetoreachhome);
}
|