13 Nisan 2010 Salı

C++ for, if, setw() ve rand() ile Rastgele Sayı Üretme

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
    for(int i=1;i<=20;i++){
            cout << setw(10) << (1+rand()%6);
            if(i%5==0)
            cout<<endl;
            }
    for(int k=1;k<=10;k++){
    cout<<(rand()%7)<<"-";
}
    cout<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder