Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "ctime"
- using namespace std;
- int main() {
- const int n = 5;
- int a[n][n];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- a[i][j] = rand() % 100 - 50;
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << a[i][j] << '\t';
- }
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (i < j) {
- a[i][j] = 0;
- }
- if (i > j) {
- a[i][j] = -1;
- }
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << a[i][j] << '\t';
- }
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (i + j < n - 1) {
- a[i][j] = -2;
- }
- if (i + j > n - 1) {
- a[i][j] = -3;
- }
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << a[i][j] << '\t';
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement