Viết chương trình bằng C để kiểm tra xem ma trận đã cho có phải là ma trận đơn vị hay khôngMảng C. Bài tập-31 có lời giải
Trình bày bằng hình ảnh
Giải pháp mẫu
Mã C
#include
//In a square matrix if all the main diagonal elements are 1's and
//all the remaining elements are 0's is called an Identity Matrix.
void main[]
{
int arr1[10][10];
int r1,c1;
int i, j, yn =1;
printf["\n\n Check whether a given matrix is an identity matrix :\n "];
printf["-----------------------------------------------------------\n"];
printf["Input number of Rows for the matrix :"];
scanf["%d", &r1];
printf["Input number of Columns for the matrix :"];
scanf["%d",&c1];
printf["Input elements in the first matrix :\n"];
for[i=0;i