Login
Register
Problem list
Online status
TheXfox
:
2024-10-09 20:46:07
这个写法有什么问题?有大佬可以解答下吗? #include
using namespace std; class X { public: X(int a=0, int b=0, int c=0) :row(a), col(b), value(c) {} int row; int col; int value; void print() { cout << row << ' ' << col << ' ' << value << endl; } void input() { cin >> row >> col >> value; } }; class Y { public: Y(int a = 0,int b=0) :size(a),start(b) {} int size; int start; }; void get(X* ar,Y* ca) { ca[1].start = 1; for (int i = 1; i <= ar[0].value; i++) ca[ar[i].col].size++; for (int i = 2; i < ar[0].col + 1; i++) ca[i].start = ca[i - 1].size + ca[i - 1].start; } void change(X* ar) { X* AR = new X[ar[0].value + 1]; Y* ca = new Y[ar[0].col + 1]; get(ar, ca); AR[0].col = ar[0].row; AR[0].row = ar[0].col; AR[0].value = ar[0].value; for (int i = 1; i <= ar[0].value; i++) { AR[ca[ar[i].col].start].col = ar[i].row; AR[ca[ar[i].col].start].row = ar[i].col; AR[ca[ar[i].col].start].value = ar[i].value; ca[ar[i].col].start++; } for (int i = 0; i <= AR[0].value; i++) AR[i].print(); } int main() { int x, i, j, v = 0; cin >> x; X** AR = new X * [x]; for (int u = 0; u < x; u++) { cin >> i >> j >> v; AR[u] = new X[v + 1]; AR[u][0].row = i; AR[u][0].col = j; AR[u][0].value = v; for (int n = 1; n <= AR[u][0].value; n++) AR[u][n].input(); } for (int u = 0; u < x; u++) { if (AR[u][0].value != 0) change(AR[u]); else cout << AR[u][0].col << ' ' << AR[u][0].row << ' ' << AR[u][0].value << endl; } return 0; }
徐鹏
:
2024-10-04 21:22:27
假的吧,在VS中运行正确,怎么放在这上面就不对了?
Lilac09
:
2021-08-16 00:10:25
这个题确定没问题吗。。
Lilac09
:
2021-08-16 00:10:10
这个题确定没问题吗。。
Post Your Comment