-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2D_v2.c
More file actions
29 lines (22 loc) · 1.07 KB
/
2D_v2.c
File metadata and controls
29 lines (22 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
//Spalten, Reihen, ich nutze hier die globale Variablen
int ematrixp(int m[3][3]){ //die Funktion prüft ob es eine Einheitsmatrix ist
int str = 3,stb=3;
int i,j,r=1; // aber sie arbeitet nicht korrekt!
if(str!=stb) r=0;
else{
for(i=0; i<str; i++){
for(j=0; j<stb; j++){
if((i==j) && (m[i][j]!=1)) r=0;
else if((i!=j) && (m[i][j]!=0)) r=0;
}}}
return r;
};
int main(){
printf("\n");
int m [3][3] = {{1,0,0},//unsere Matrix, die geprüft wird
{1,1,0},
{0,0,1}};
printf("%d \n", ematrixp(m));//0-falls keine Einheitsmatrix, 1- falls Einheitsmatrix
return 0;
}