Kurang lebihnya tampilan
Coding :
#include<cstdlib>
#include<iostream>
#include<time.h>
using namespace std;
void wait ( double seconds )//fungsi timing
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main(int argc, char *argv[])
{
for(int i=15;i>=0;i--){
system("cls");//penghapus layar
cout<<"==========================================="<<endl;
cout<<" MERAH (STOP) "<<endl;
cout<<"==========================================="<<endl;
cout<<"Lampu akan kuning dalam hitungan :"<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<"\t"<<i;wait(1);//pemberian waktu
}
for(int i=10;i>=0;i--){
system("cls");//penghapus layar
cout<<"==========================================="<<endl;
cout<<" KUNING (HATI-HATI) "<<endl;
cout<<"==========================================="<<endl;
cout<<" Lampu akan hijau dalam hitungan :"<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<"\t"<<i;wait(1);//pemberian waktu
}
system("cls");//penghapus layar
cout<<"==========================================="<<endl;
cout<<" HIJAU (SILAKAN JALAN)"<<endl;
cout<<"==========================================="<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}