С++ Випадкові

2075 / C++ / Випадкові числа

 

#include <iostream>
#include <time.h>
using namespace std;

int main()
{
  srand(time(0));
  int a = rand() % 100; // не можна писати в double
  cout << a << endl;

  system("pause");
  return 0;
}

 

time(0) // Дата в секундах з 1 січня 1970

cout << "Кількість годин з 1 січня 1970 = " << time (0)/3600 << endl;