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

1 vue (au cours des 30 derniers jours)
ishwarya ramesh
ishwarya ramesh le 29 Mar 2018
Modifié(e) : Birdman le 29 Mar 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;
}

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by