//ID: 19127640 //Name :Hoang Huu Giap //19CLC6 #include using namespace std; #define M 100 void NhapMang(int a[][M], float row, float col) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { cout << "a[" << i << "][" << j << "] ="; cin >> a[i][j]; } cout << endl; } } void XuatMang(int a[][M], float row, float col) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { cout << a[i][j] << "\t"; } cout << endl; } } int CheckSNT(int m) { int dem = 0; for (int i = 1; i <= m; i++) { if (m % i == 0) dem += 1; } if (dem == 2) return 1; return 0; } int LietKe(int n) { int i = n + 1; for (;; i++) { if (CheckSNT(i) == 1) break; } return i; } void ThayMang(int a[][M], float row, float col) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (CheckSNT(a[i][j]) == 0) { a[i][j] = LietKe(a[i][j]); } } } } int main() { int a[M][M]; float row, col; cout << "Input row:"; cin >> row; cout << "Input collum:"; cin >> col; NhapMang(a, row, col); XuatMang(a, row, col); cout << "Mang sau khi thay the la:" << endl; ThayMang(a, row, col); XuatMang(a, row, col); return 1; }