#include #define MAX_ROWS 100 #define MAX_COLS 100 // Hàm để nhập ma trận từ bàn phím void inputMatrix(float matrix[][MAX_COLS], int rows, int cols) { printf("Nhập ma trận:\n"); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { printf("Nhập phần tử (%d, %d): ", i + 1, j + 1); scanf("%f", &matrix[i][j]); } } } // Hàm để in ma trận ra màn hình dưới dạng bảng void printMatrix(float matrix[][MAX_COLS], int rows, int cols) { printf("Ma trận:\n"); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { printf("%.2f\t", matrix[i][j]); } printf("\n"); } } // Hàm để tính tích các phần tử thuộc các cột lẻ của ma trận float calculateProductOfOddColumns(float matrix[][MAX_COLS], int rows, int cols) { float product = 1.0; for (int j = 1; j < cols; j += 2) { for (int i = 0; i < rows; i++) { product *= matrix[i][j]; } } return product; } // Hàm để tìm giá trị và vị trí của phần tử lớn nhất trong ma trận void findMaxElement(float matrix[][MAX_COLS], int rows, int cols, float* maxElement, int* maxRow, int* maxCol) { *maxElement = matrix[0][0]; *maxRow = 0; *maxCol = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (matrix[i][j] > *maxElement) { *maxElement = matrix[i][j]; *maxRow = i; *maxCol = j; } } } } int main() { int m, n; printf("Nhập số hàng m: "); scanf("%d", &m); printf("Nhập số cột n: "); scanf("%d", &n); float matrix[MAX_ROWS][MAX_COLS]; inputMatrix(matrix, m, n); printMatrix(matrix, m, n); float product = calculateProductOfOddColumns(matrix, m, n); printf("Tích các phần tử thuộc các cột lẻ: %.2f\n", product); float maxElement; int maxRow, maxCol; findMaxElement(matrix, m, n, &maxElement, &maxRow, &maxCol); printf("Phần tử lớn nhất trong ma trận: %.2f\n", maxElement); printf("Vị trí của phần tử lớn nhất: hàng %d, cột %d\n", maxRow + 1, maxCol + 1); return 0; }