Quick actions

cmd+k|ctrl+k

Navigation

Languages

989

Snippet info

Language

Cpp

Visibility

public

Author

nxnxngh

Created

2018-11-28T22:23:27Z

Updated

2018-12-04T21:43:38Z

#include <iostream>
#include<ctime>

using namespace std;

int main()
{
	srand(time(NULL));
	setlocale(LC_ALL, "ru");
	//Creation
	int row = 6;
	int cols = 3;
	int m = 0;
	int **mass = new int* [row];
	for (int i = 0; i < row; i++)
	{
		mass[i] = new int[cols];
	}
	//Generating element value
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < cols; j++)
		{
			mass[i][j] = rand()%130;
			cout << mass[i][j] << "\t";
		}
		cout << endl;
	}
    //check if sum of elements 4  digits number
    cout << endl<< endl;
    	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < cols; j++)
		{
			m = m + mass[i][j];
		}
	}
	cout<<"m = "<<m<<endl;
	if(m>=1000 && m<=9999)
	{
	    cout<<m<<" - четырехзначное число";
	}
	else
	{
	    cout<<m<<" - не четырехзначное число";
	}
	//Deleting
	for (int i = 0; i < row; i++)
	{
		delete[] mass[i];
	}
	delete[] mass;
	system("PAUSE");
	return 0;
}
INFO