#include <stdio.h>#include <stdlib.h>#include <conio.h> /* main program fucntion */void main(){ int iMatrSize, // size of the matrix iSum = 0, // sum of the nessesary elements of the matrix iCnt = 0, // number of the nessesary elements of the matrix **aMatr; // the matrix int i, j; scanf_s("%i", &iMatrSize); /* allocation memory for the array */ aMatr = (int**)malloc(sizeof(int) * iMatrSize); for (i = 0; i < iMatrSize; i++) { aMatr[i] = (int*)malloc(sizeof(int) * iMatrSize); } /* filling in the array */ for (i = 0; i < iMatrSize; i++) for (j = 0; j < iMatrSize; j++) aMatr[i][j] = rand() % 21 - 10; /* counting the sum of the elements */ for (i = 0; i < iMatrSize; i++) for (j = 0; j < iMatrSize - i - 1; j++) iSum += aMatr[i][j], iCnt++; /* outputing the array */ for (i = 0; i < iMatrSize; i++) { for (j = 0; j < iMatrSize; j++) printf ("%3i ", aMatr[i][j]); printf("\n"); } printf("Sum = %f\n", (float)iSum / iCnt); _getch();} /* End of 'main' function */
Дано: Учеб - 200 стр 1 стр - 35 строк 1 строка - 50 символов Решение: 1) 50*35=1750 (символов) - на одной странице 2) 1750*200=350000 (символов) - в учебнике 3) так как в задаче не указан метод кодировки, то будем использовать кодировку ASCII ( в ней 1 символ равен 1 байту, также есть кодировка UNICODE, в которой 1 символ равен 2 байтам). Итак, 1 символ = 1 байту, тогда 350000*1=350000 (байт) 350000/1024 = 341,7 (Кб) - объём одного учебника. 4) переведём 2 Гб в Кб 2 Гб*1024 = 2048 (Мб) 2048*1024= 2 097 152 (Кб) 5) Разделим полученный объём на объём одного учебника: 2 097 152/341,7 = 6137 (учебников)