[ nemanja11111 @ 15.01.2011. 13:31 ] @
| Pozdrav ljudi, evo sta je problem:
Recimo unesem 2 broja (x i y) i sad recimo, x=0. Kako sad da vezem neku random vrednost za taj broj? Pa da x vise ne bude 0, nego nasumicni broj. Npr nesto kao if x=0; then x=rand |
[ Nedeljko @ 15.01.2011. 17:01 ] @
Code:
#include <ctime>
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
int x;
srand(time(0));
cin >> x;
if (x == 0) {
x = rand();
}
cout << x << endl;
return EXIT_SUCCESS;
}
Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.