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

조회 수: 1 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by