
Герберт
5 год назад
заменить значения всех отрицательных элементов матрицы на нулевые с помощью языка С. КАК? Пожалуйста посчитайте ПОЖАЛУЙСТА
ОТВЕТЫ

Daniel
Oct 24, 2020
#include <stdio.h>
#include <cstdlib>
#include <ctime>
const unsigned int n = 5;
const unsigned int m = 6;
int main()
{
srand(time(NULL));
int i, j;
int a[n][m];
printf("nSource:n");
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
a[i][j] = rand() % 201 - 100;
printf("%dt", a[i][j]);
}
printf("n");
}
printf("nResult:n");
for ( i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
if (a[i][j] < 0) a[i][j] = 0;
printf("%dt", a[i][j]);
}
printf("n");
}
getchar();
}
#include <cstdlib>
#include <ctime>
const unsigned int n = 5;
const unsigned int m = 6;
int main()
{
srand(time(NULL));
int i, j;
int a[n][m];
printf("nSource:n");
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
a[i][j] = rand() % 201 - 100;
printf("%dt", a[i][j]);
}
printf("n");
}
printf("nResult:n");
for ( i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
if (a[i][j] < 0) a[i][j] = 0;
printf("%dt", a[i][j]);
}
printf("n");
}
getchar();
}
369
Смежные вопросы: