To learn to write a simple c + +, array assignment application, with the DEV of c + + 5.11.
Out of a strange question, comment the line in the program can lead to circulation can't jump out, thought for a long time do not understand,
#include
using namespace std;
Int main () {
Unsigned char c=0, d=0;
Unsigned int e [255] [255].
Do {
if(! (255) (int) c ^) {
break;
}
C + +;
D=0;
Do {
Cout & lt; <(int) c & lt; <", "& lt; <(int) d & lt;
Cout<[" e "& lt; & lt; (int) c & lt; & lt;"] "& lt; <"[" & lt; & lt; (int) d & lt; & lt;"] "& lt; <":" & lt;
break;
}
D++;
} the while (1);
} the while (1);
return 0;
}
CodePudding user response:
Reference:# include & lt; Iostream>
using namespace std;
Int main ()
{
Unsigned char c=0, d=0;
Unsigned int e [255] [255].
Do {
if(! (254) (int) c ^) {//an array subscript is a scale of 0-254255 to cross-border
break;
}
C + +;
D=0;
Do {
Cout & lt; <(int) c & lt; <", "& lt; <(int) d & lt;E [c] [d]=c + d;//this line can not jump out of the loop,
Cout<[" e "& lt; & lt; (int) c & lt; & lt;"] "& lt; <"[" & lt; & lt; (int) d & lt; & lt;"] "& lt; <":" & lt;if(! (254) (int) ^ d) {//an array subscript is a scale of 0-254255 to cross-border
break;
}
D++;
} the while (1);
} the while (1);
System (" pause ");
return 0;
}
//output:
//1, 0
//e [1] [0] : 1
//1, 1
//e [1] [1] : 2
//1, 2
//e [1] [2] : 3
//...
//...
//e [1] [253] : 254
//1254
//e [1] [254] : 255
//2, 0
//e [2] [0] : 2
//2, 1
//e [2] [1] : 3
//2, 2
//e [2] and [2] : 4
//2, 3
//e [2] [3] : 5
//...
//...
//254250
//e [254] [250] : 504
//254251
//e [254] [251] : 505
//254252
//e [254] [252] : 506
//254253
//e [254] [253] : 507
//254254
//e [254] [254] : 508
//please press any key to continue...
CodePudding user response:
Starting from 0, also need to adjust the sentence order, still have to wait for it some time:# include & lt; Iostream>
using namespace std;
Int main ()
{
Unsigned char c=0, d=0;
Unsigned int e [255] [255].
Do {
D=0;
Do {
Cout & lt; <(int) c & lt; <", "& lt; <(int) d & lt;E [c] [d]=c + d;
Cout<[" e "& lt; & lt; (int) c & lt; & lt;"] "& lt; <"[" & lt; & lt; (int) d & lt; & lt;"] "& lt; <":" & lt;if(! (254) (int) ^ d) {//an array subscript is a scale of 0-254255 to cross-border
break;
}
D++;
} the while (1);
if(! (254) (int) c ^) {//an array subscript is a scale of 0-254255 to cross-border
break;
}
C + +;
} the while (1);
System (" pause ");
return 0;
}
//output:
//0, 0
//e [0] [0] : 0
//0, 1
//e [0] [1] : 1
//0, 2
//e [0] [2] : 2
//0, 3
//e [0] [3] : 3
//0, 4
//e [0] [4] : 4
//...
//...
//1, 0
//e [1] [0] : 1
//1, 1
//e [1] [1] : 2
//1, 2
//e [1] [2] : 3
//...
//...
//e [1] [253] : 254
//1254
//e [1] [254] : 255
//2, 0
//e [2] [0] : 2
//2, 1
//e [2] [1] : 3
//2, 2
//e [2] and [2] : 4
//2, 3
//e [2] [3] : 5
//...
//...
//254250
//e [254] [250] : 504
//254251
//e [254] [251] : 505
//254252
//e [254] [252] : 506
//254253
//e [254] [253] : 507
//254254
//e [254] [254] : 508
//please press any key to continue...
CodePudding user response:
Can be seen from the breakpoint debugging, variable c, and d is placed behind the array e, the code in the array operation of crossing the line, is the one line of code that added annotations for cross-border operation (array subscript is legally 0-254), covering the c, d value, the loop will not terminate,