为什么VS C++总是出现断点,怎么解决?
题目的结果都是对的。
题目如下:
代码如下:
#include <iostream>
using namespace std;
class PHALANX {
int(*p)[20];
int startnum;
int n;
public:
PHALANX(int s, int m) {
startnum = s;
n = m;
p= new int[n][20];
}
void process();
void print() {
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++)
cout << p[i][j]<<'\t';
cout << endl;
}
}
~PHALANX() {
delete[n]p;
}
};
void PHALANX::process() {
p[0][0] = startnum;
for (int i = 1; i < n; i++) {
p[i][i] = p[i - 1][i - 1] + i * 2;
for (int j = i; j >= 0; j--)
p[j - 1][i] = p[j][i] - 1;
for (int j = i; j >= 0; j--)
p[i][j - 1] = p[i][j] + 1;
}
};
int main() {
int s, m;
cin >> s >> m;
PHALANX c(s, m);
c.process();
c.print();
return 0;
}
结果如下:
问题如下: