Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
827 B
1
Indexable
Never

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//пользователь вводит номер строки - найти минимальный элемент

int main( void ) {

	srand( time( 0 ) );

	const int rows = 4, cols = 5;
	int arr[ rows * cols ];

	int i, j;
	for ( i = 0; i < rows * cols; ++i )
		arr[ i ] = 1 + rand() % 100;

	for ( i = 0; i < rows; ++i ) {
		for ( j = 0; j < cols; ++j )
			printf( "%5d", arr[ i * cols + j ] );

		puts( "" );
	}

	printf( "Введите номер строки: ");
	int num;
	scanf( "%d", &num );
	--num;

	int min = arr[ cols * num ];
	for ( j = 1; j < cols; ++j )
		if ( arr[ cols * num + j ] < min )
			min = arr[ cols * num + j ];

	printf( "Минимальный элемент в указанной строке = %d\n", min );


	return EXIT_SUCCESS;
}