Untitled
unknown
c_cpp
2 years ago
1.9 kB
11
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
// Дана квадратная матрница размером 7 x 7, которая хранится в одномерном массиве.
// Найти минимальный элемент под главной диагональю
// Найти среднее арифметическое над побочной диагональю, включая побочную диагональ
// 1 2 3 4
// 5 6 7 8
// 9 0 1 -1
// 4 7 8 2
// 1 2 3 4 5 6 7 8 9 0 1 -1 4 7 8 2
//[0] [4][5] [8][9][10]
void FillArr(int *arr, const int rows, const int cols ) {
int i;
const int size = rows * cols;
for (i = 1; i < size; i++ )
arr[i] = rand() % 11 - 5;
}
void PrintArr(int *arr, const int rows, const int cols) {
int i,j;
for (i = 0; i < rows; i ++) {
for (j = 0; j < cols; j++)
printf("%5d", arr[i * cols + j]);
puts("");
}
}
int MinElem(const *int, const int size, const int cols, const int rows) {
int i,j;
int min = arr[0];
for (i = 0; i < rows-1; i++)
for (j = 0; )
if (arr[i] < min)
min = arr[i];
return min;
}
double GetAvg(const int *arr, const int numRow, const int cols) {
int i,j;
double sum = 0;
for (i = 0; i < rows - 1; i++) {
for (j = )
sum += arr[i];
count += 1;
}
return sum / count;
}
int main() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
srand(time(0));
const int rows = 7, cols = 7;
const int size = cols * rows;
int arr[size];
GetAvg(arr, rows, cols)
MinElem(arr, rows, cols)
FillArr(arr, rows, cols); // имя массива - это указатель на первый элемент
PrintArr(arr, rows, cols);
}
Editor is loading...