I don't mean "iostream.h" or missng "return 0;". I wonder why don't run like it should but shows "press eny key continue"?

#include <iostream.h>

int n,m,result,br=0;
int a[100][100];
int jj=0;
void main() {
	cout<<"n?"; cin>>n;
		cout<<"m?"; cin>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++) {
			cout<<"a["<<i<<"]["<<j<<"]=";
			cin>>a[i][j]; }
		for(int ii=0;ii<n;ii++)
		for(int jj=0;jj<m;jj++) {
			if(a[ii][jj]==a[ii++][jj++]) br++; result=a[ii][jj]; }
				if(br>2) {
				
			     cout<<result; }

}

Which compiler should I use?

Use whatever compiler you want. If you're running it through an IDE, some IDEs keep the console window open with the "Press any key..." message. Dev C++ will run all the way through without showing that message. The console window just closes when the program is done. Regardless of the compiler, if you run the program outside of an IDE, it won't give you that "Press any key..." message.

Many compilers will automatically put a function saying:
cout<<"Press any key to continue...";
system("PAUSE");

As so you can still view your work when it is finished. This is because once the program has nothing left to do it will exit, to help prevent this the compiler puts system("PAUSE");

I suggest that you get Dev C++ Bloodshed, it does not automatically put these functions at the end of the code. Instead if you still need to view things after your program has complete I suggest you put cin.get(); as this will wait for the user to hit enter before the program exits.

-Inkcoder

And another thing

void main () {}

In many new c++ compilers is not acceptable.because it is deprecated or something . I prefer that you use

int main () {}

You could also put this at the end:

cout << "\nDo you want to run this program again? Y/N:\t";
cin >> ExitOr;
    if (ExitOr == 'n')
        exit(1);
    else
    {
        if (ExitOr == 'y')
        {
            main();
        }
    }

and add this after int main():

char ExitOr;

This or inkcoder's way work just as well, except this way you can choose to run the program again without having to open it again, inkcoder's way is just hit a key and program closes.

This article has been dead for over six months. Start a new discussion instead.