Monday, November 18, 2013

Code Perulangan (for) Sederhana disertai Timer

Contoh Kode Perulangan di C++ menggunakan MinGWStudio :
#include <iostream.h>
#include <windows.h>
#include <conio.h>
#define sleep(n) Sleep(1000 * n)

using namespace std;
int main() {
    /*cout << "Sleeping for 1 sec..." << flush;
   sleep(1);
    */
    int a, b, c;
    cout<<"Masukkan Nilai Deret= ";cin>>a;
    for(b=1; b<=a; b++)
    {
        for(c=1; c<=b; c++)
        {
            cout<<b<<"";

sleep(0.5);
//a++;
        }
        cout<<" "<<endl;
    }
    return 0;

}

Hasilnya :
Selamat Mencoba :)



No comments:

Post a Comment