Matricea, e urgent !!!
Răspunsuri la întrebare
Varianta cu matrici normale:
#include <iostream>
using namespace std;
bool mat[21][21];
bool compl[21];
int main(){
int n,m,x;
cin >> m >> n;
for(int i = 0; i < m-1; i++)
compl[i] = true;
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++){
cin >> x;
mat[i][j] = x == 1;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m-1; j++){
if(compl[j])compl[j] = mat[m-1][i] != mat[j][i];
}
}
int k = 0;
for(int j = 0; j < m-1; j++)
if(compl[j])
k++;
cout << k;
return 0;
}
Varianta cu vectori si biti:
#include <iostream>
using namespace std;
int mat[21];
int main(){
int m,n,x;
cin >> m >> n;
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++){
cin >> x;
mat[i] = (mat[i] << 1) | (x);
}
int k = 0;
for(int i = 0; i < m-1; i++){
if(((mat[i] & (mat[m-1])) & ((1 << n) - 1)) == 0)
k++;
}
cout << k;
return 0;
}