把多个数组变成一个一个数组—struct _____(1)

发布时间:2026/7/4 20:48:26
把多个数组变成一个一个数组—struct _____(1) Hi 大家好我是猴子修。大家是不是对sort两个数组同样运动感到无比难受在此struct闪亮登场。首先可以用普通的文件头像文件头#includebits/stdc.h这样的文件头等等。然后在#includebits/stdc.h using namespace std; struct a//这里 { int x; int y; }; a s[1005]; bool npc(a z,a z1) { return z.xz1.x; } int main() { int n; cinn; for(int i1;in;i) { cins[i].xs[i].y; } sort(s1,sn1,npc); for(int i1;in;i) { couts[i].x,s[i].y } return 0; }也可以这样写#includebits/stdc.h using namespace std; struct a//这里 { int x; int y; }; a s; int main() { cins.xs.y; swap(s.x,s.y); couts.xs.y; return 0; }这样写struct 名{变量1变量2……}声明 变量/数组^.o.^) !求赞