Preview:
#include <iostream>
#include <cstdlib> // Для функции rand()
#include <ctime>   // Для функции time()

int main() {
    
//part one
    
    std::srand(std::time(nullptr));

    int array[12], sump = 0, countp = 0,sumn = 0, countn = 0;

    for (int i = 0; i < 12; i++) {
        array[i] = -100 + std::rand() %201;
    }

    std::cout << "Array: ";
    for (int i = 0; i < 12; i++) {
        std::cout << array[i] << " ";
    }
    std::cout << std::endl;

    for (int i = 0; i < 12; i++) {
        if (array[i] > 0) {
            sump += array[i];
            countp++;
        } else if (array[i] < 0) {
            sumn += array[i];
            countn++;
        }
    }


    std::cout << "Sum of positive numbers: " << sump << std::endl;
    std::cout << "Number of positive numbers: " << countp << std::endl;
    std::cout << "Сумма отрицательных чисел: " << sumn << std::endl;
    std::cout << "Количество отрицательных чисел: " << countn << std::endl;



//part two


    int posarray[countp], negarray[countn], indpos = 0, indneg = 0;
    
    for (int i = 0; i < 12; i++) {
        if (array[i] > 0) {
            posarray[indpos] = array[i];
            indpos++;
        } else if (array[i] < 0) {
            negarray[indneg] = array[i];
            indneg++;
        }
    }
    
    std::cout << "Positive array: ";
    for (int i = 0; i < countp; i++)
        std::cout << posarray[i] << " ";
    
    std::cout << std::endl;
    
    std::cout << "Negative array: ";
    for (int i = 0; i < countn; i++)
        std::cout << negarray[i] << " ";
    
    std::cout << std::endl;
    
//part three
    
    int matrix[6][6];

    for (int i = 0; i < 6; i++) 
        for (int j = 0; j < 6; j++) 
            matrix[i][j] = std::rand() % 100;

    std::cout << "Matrix :" << std::endl;
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 6; j++) 
            std::cout << matrix[i][j] << "\t";
            
        std::cout << std::endl;
    }

    std::cout << "Numbers under main diagonal or on it :" << std::endl;
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 6; j++)
            if (i >= j) 
                std::cout << matrix[i][j] << "\t";
                
        std::cout << std::endl;
    }
    
    
    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter