Var a: integer;begin read(a); if (a >= 1) and (a <= 31) then write(a,' ',1); if (a >= 32) and (a <= 59) then write((a - 31),' ',2); if (a >= 60) and (a <= 90) then write((a - 59),' ',3); if (a >= 91) and (a <= 120) then write((a - 90),' ',4); if (a >= 121) and (a <= 151) then write((a - 120),' ',5); if (a >= 152) and (a <= 181) then write((a - 151),' ',6); if (a >= 182) and (a <= 212) then write((a - 181),' ',7); if (a >= 213) and (a <= 243) then write((a - 212),' ',8); if (a >= 244) and (a <= 273) then write((a - 243),' ',9); if (a >= 274) and (a <= 304) then write((a - 273),' ',10); if (a >= 305) and (a <= 334) then write((a - 304),' ',11); if (a >= 335) and (a <= 365) then write((a - 334),' ',12); readln; readlnend.
#include <iostream>
#include <ctime>
int N = NULL;
int main() {
srand((unsigned int)time(NULL));
std::cout << "Enter the N: ";
std::cin >> N;
int** matrix = new int*[N];
for (int i = 0; i < N; i++) {
matrix[i] = new int[N];
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
matrix[i][j] = rand() % 100;
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
std::cout << matrix[i][j] << " ";
}
std::cout << std::endl;
}
for (int i = 0; i < N; i++) {
delete[] matrix[i];
}
delete[] matrix;
return 0;
}
Объяснение:
Данные матрицы — случайные числа
Память на массивы выделяется динамически, затем чистится.