FuryMan, #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> #define RAND(min, max) (rand() % ((max) - (min)) + (min)) using namespace std; int main() { srand(unsigned(time(nullptr))); auto w = 6U; int box[10][10]; for (auto& row : box) { for (auto& x : row) { x = RAND(0, 1000); cout << setw(w) << x; } puts(""); } system("pause > nul"); }
FuryMan, #include <stdio.h> #include <stdlib.h> #include <time.h> #define N 10U #define RAND(min, max) (rand() % ((max) - (min)) + (min)) int main(void) { int box[N][N]; size_t i, j; srand((unsigned)time(NULL)); for (i = 0U; i < N; ++i) { for (j = 0U; j < N; ++j) { box[j] = RAND(0, 1000); printf("%6i", box[j]); } puts(""); } return 0; }
Такие программы относятся к ультра-коротким, укладывающиися всего в несколько строк: #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> using namespace std; int main() { int a[10][10], i, j; srand(time(0)); for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { a[j] = rand() % 1001; cout << setw(5) << a[j]; } cout << endl; } system("pause > nul"); return 0; }