i have a code in c language and i need it in matlab so plz kindly help....

1 Ansicht (letzte 30 Tage)
ishwarya ramesh
ishwarya ramesh am 29 Mär. 2018
Bearbeitet: Birdman am 29 Mär. 2018
#include <time.h>
#include <conio.h>
#include <stdio.h>
int main()
{
time_t strt, t;
long difference = 0;
int a, progrun;
char start;
printf("Press 1 to turn on the Traffic Light\n");
scanf_s("%d", &progrun);
if (progrun == 1)
{
strt = time(NULL);
printf("East-West Signal North-East Signal\n");
while (difference < 15)
{
t = time(NULL);
difference = t - strt;
int light(difference);
if (difference <= 3)
{
printf("Red Light Green Light\r");
fflush stdout;
}
else if (difference > 3 && difference <= 6)
{
printf("Red Light Yellow Light\r");
fflush stdout;
}
else if (difference > 6 && difference <= 8)
{
printf("Red Light Red Light\r");
fflush stdout;
}
else if (difference > 8 && difference <= 10)
{
printf("Yellow Light Red Light\r");
fflush stdout;
}
else if (difference > 10 && difference <= 12)
{
printf("Green Light Red Light\r");
fflush stdout;
}
else if (difference > 12 && difference <= 14)
{> printf("Yellow Light Yellow Light\r");
fflush stdout;
}
}
}
_getch();
return 0;
}

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by