Answer the question
In order to leave comments, you need to log in
How to fill a two-dimensional array with a one-dimensional one?
I have a code, but when I start the replacement, then I only change one line, and then it doesn't display anything.
Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
#include <math.h>
#define N 100
#define M 100
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
srand(time(0));
int arr[N][M], n, m, a, b, one_arr[N],i,j,l,q,s, arr1[N][M];
printf("Введите N = "); scanf_s("%d", &n);
printf("Введите M = "); scanf_s("%d", &m);
printf("Введите начало кординат для рандома = "); scanf_s("%d", &a);
printf("Введите конец кординат для рандома = "); scanf_s("%d", &b);
if (n < N && m < M && a < b) {
printf("Двухмерный массив:\n");
for ( i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
arr[n][m] = a + rand() % (b - a + 1);
printf("%4d", arr[n][m]);
}
printf("\n");
}
printf("Одномерный массив:\n");
for ( i = 0; i < n*m; i++) {
one_arr[i] = a + rand() % (b - a + 1);
printf("%4d", one_arr[i]);
}
int count = 0;
// Заполнение
printf("\n Result\n");
printf("%d", one_arr[1]);
for (i = 0; i < n; i++) {
for ( j = 0; j < m; j++); {
arr[n][m] = one_arr[count];
printf("%4d", arr1[i][j]);
count++;
}
printf("\n");
}
}
else {
printf("Веденные некорректные данные");
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
#include<iostream>
#include<iomanip> // для красивого вывода матрицы
using namespace std;
int main()
{
short Array1[7][7];
short Array2[49];
srand(time(NULL));
size_t temp_y{ 0 }, temp_x{ 0 }; // переменные (беззнакового типа)
// для перемещения по матрице при заполнении
for (auto x = 0; x < 49; x++)
{
Array2[x] = rand() % 100;
Array1[temp_x][temp_y++] = Array2[x];
if (temp_y == 7) // при заполнении крайнего столбца матрицы курсор перемещается
{
temp_x++; // на следующую строку
temp_y = 0; // в первый столбец
}
}
for (auto f = 0; f < 49; f++)
{
cout << setw(5) << Array2[f];
}
cout << endl << endl;
for (auto x = 0; x < 7; x++)
{
for (auto f = 0; f < 7; f++)
{
cout << setw(5) << Array1[x][f];
}
cout << endl;
}
return 0;
}
If there is a video recording of 24 hours, how to view it in 5 minutes?
Video analytics systems are used for such tasks.
That is, for the video, a motion detector, a line crossing detector, a direction detector, a detector of the presence of persons in the frame are set. Then the software processes the video and shows only the frames where the detectors worked.
General advice: Google for the name "video analytics".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question