bool

int count=0;
for(i=0; i<size; i++){
for(j=0; j<size; j++){
if(x[i][j] == y[i][j]){
count++;
continue;
}
else
break;}
}
if(count==9)
cout << "Idempotent";
any simple method to check this two matrix?
Please help me
Thank you
Last edited on
#include<iostream>
#include<conio.h>
#define size 3
using namespace std;

void main(){

int a[3][3]={{2,3,4} , {1,2,3}, {4,5.6}};
int b[3][3]= {{2,3,4} , {1,2,3}, {4,5.6}};
bool check (int [][3], int [][3]);
_getch;
}
bool check(int c[][3], int d[][3])
{
bool flag = 0;

for(int i = 0; i < 3; i++)
for(int j=0; j<3; j++) {
if(c[i][j] == d[i][j])
flag = 1;
}

return flag;
}
If i want to use flag,how to use?
What to change in this program
What to change in this program
You're not calling the function check. Instead it is the prototyp. Change it like so:
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
30
31
32
#include<iostream>
#include<conio.h>
#define size 3
using namespace std;

bool check (int [][3], int [][3]); // Note

void main(){

int a[3][3]={{2,3,4} , {1,2,3}, {4,5.6}};
int b[3][3]= {{2,3,4} , {1,2,3}, {4,5.6}};
if(check (a, b)) // Note
  cout << "identical"; // Note
_getch(); // Note
}
bool check(int c[][3], int d[][3])
{
bool flag = false; // Note

for(int i = 0; i < 3; i++)
for(int j=0; j<3; j++) {
if(c[i][j] == d[i][j])
flag = true; // Note
else // Note
{
  flag = false; // Note
  break; // Note
}
}

return flag;
} 
but if it is not identical,it still cout identical
wait you're right. Do this:
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<iostream>
#include<conio.h>
#define size 3
using namespace std;

bool check (int [][3], int [][3]); // Note

void main(){

int a[3][3]={{2,3,4} , {1,2,3}, {4,5.6}};
int b[3][3]= {{2,3,4} , {1,2,3}, {4,5.6}};
if(check (a, b)) // Note
  cout << "identical"; // Note
_getch(); // Note
}
bool check(int c[][3], int d[][3])
{
bool flag = false; // Note

for(int i = 0; i < 3; i++)
for(int j=0; j<3; j++) {
if(c[i][j] == d[i][j])
flag = true; // Note
else // Note
  return false; // Note
}

return flag;
} 
Thank you very much,you help me a lot.
Topic archived. No new replies allowed.