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

2 ビュー (過去 30 日間)
ishwarya ramesh
ishwarya ramesh 2018 年 3 月 29 日
編集済み: Birdman 2018 年 3 月 29 日
#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;
}

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by