Home > Back-end >  C language running automatically closes the window
C language running automatically closes the window

Time:11-25

 # include 
using namespace std;
Int con [10]=,1,2,3,4,5,6,7,8,9 {0};
Int vir [8] [2]={{1, 0}, {0, 1}, {1, 0}, {0, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
Int ans.
//check whether this situation can
Bool LL (int mp [] [6], int x, int y) {
/* for (int I=0; i<5; I++) {
for(int j=0; J<6; J++) {
Printf (" % 4 d ", mp [I] [j]);
} cout} */
for(int i=0; i<8; I++) {
Int tx=x + vir [I] [0];
Int ty=y + vir [I] [1];
If (fabs (mp [x] [y] - mp (tx) [ty])==1) return true;
}
return false;
}
Bool check () {
Int mp [5] [6], tt=0;
for(int i=0; i<5; I++) {
for(int j=0; J<6; J++) {
Mp [I] [j]=- 10;
}
}
//memset (mp, 1, sizeof (mp));

For (int I=2; i<=4; I++) {
Mp [1] [I]=con [tt++];
}
for(int i=1; i<=4; I++) {
Mp [2] [I]=con [tt++];
}
for(int i=1; i<=3; I++) {
Mp [3] [I]=con [tt++];
}

for(int i=0; i<5; I++) {
for(int j=0; J<6; J++) {
If (LL (mp, I, j)) {
return false;
}
}
}
/* for (int I=0; i<5; I++) {
for(int j=0; J<6; J++) {
Printf (" % 5 d, "mp [I] [j]);
} cout}
Printf ("=======================================\ n "); */
return true;
}
//the whole arrangement
Void permutation (int k) {
If (k==10) {
If (check ()) {
//printf (" \ n \ n % d ", ans);
/* for (int I=0; i<10; I++) {
Printf (" % d ", con [I]);
} printf (" \ n "); */
ans++;
}
return;
}
for(int i=k; i<10; I++) {
Swap (con [k], con [I]);
Permutation (k + 1);
Swap (con [k], con [I]);
}
}
Int main () {
Permutation (0);
Coutsystem("pause");
return 0;
}



Why do I this program must be combined with the system (" puase ") can see the results, or we'll automatically closes the window, the program has a problem? Haven't this kind of situation

CodePudding user response:

Pause can let the pause; If without pause, the program runs too fast, fast to we need to pause to see results,

CodePudding user response:

After the completion of the compilation, under the command line start an executable program try...

CodePudding user response:

reference 1st floor mzhan017 response:
pause can let the pause; Without pause, programs run too fast, quick to see the results, we need to pause to

Is program is already running out directly to close the window

CodePudding user response:

reference 3 floor if man replies:
Quote: refer to 1st floor mzhan017 response:
pause can let the pause; Without pause, programs run too fast, quick to see the results, we need to pause to

Is the program has been running over to close the window directly

Program there is no problem, the main function of the main operation after the return, at the same time window is closed

CodePudding user response:

It is to close the window, you can use the file operations

CodePudding user response:

the strongest source of reference 5 floor response:
is to close the window, you can use the file operations

Other program can not ah
  • Related