bool function

how to use bool to identified a identity matrix
You need to define a 2D array of bool.
#include <fstream>
#include<iostream>
#include <iomanip>
#include <stdlib.h>
#include <conio.h>
#include <cmath>
bool check( int[][3] , int);
using namespace std;
#define size 3

void main()
{
int b=0;
int c[3][3] ={ {1,0,0},{0,1,0},{0,0,1}};
if(check(c,b))
cout << "It is a identity function";
else
cout << "not";
_getch();
}
bool check ( int d[][3], int e)
{
bool flag= false;
for(int i=0; i<3; i++){
for (int j=0; j<3; j++){
if ( !(i=j)){
if( d[i][i]== e )
flag=true;
else
return false;
}
else{
if(d[i][j]== d[i][j])
flag=true;
else
return false;
}
}
return flag;
}
}
Is it any wrong with my program?
I can just cout not,i fail to cout identity function.
#include <fstream>
#include<iostream>
#include <iomanip>
#include <stdlib.h>
#include <conio.h>
#include <cmath>
bool check( int[][3] , int);
using namespace std;
#define size 3

void main()
{
int b=0;
int c[3][3] ={ {1,0,0},{0,1,0},{0,0,1}};
if(check(c,b))
cout << "It is a identity function";
else
cout << "not";
_getch();
}
bool check ( int d[][3], int e)
{
bool flag= false;
for(int i=0; i<3; i++){
for (int j=0; j<3; j++){
if ( !(i=j)){
if( d[i][i]== e )
flag=true;
else
return false;
}
else{
if(d[i][j]== d[i][j])
flag=true;
else
return false;
}
}
return flag;
}
}
Is it any problem with this program?
i can just cout not.
Have you tried stepping through it with a debugger? That will show you which conditions are evaluating to true or false, which will show you what's going wrong.

Also, please use code tags when posting code, to make it readable.
sorry,i solve it already.Thank you,is syntax error.
Topic archived. No new replies allowed.