我有一个包含硬编码数据的结构,但是我不知道如何让 c++ 显示数据。我正在尝试的是:
#include <iostream>
using namespace std;
const int MAX = 8;
struct test {
int x[MAX] = { 16, 21, 308, 45, 51, 63, 17, 38 };
float y[MAX] = { 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5 };
int z[MAX] = { 8, 7, 6, 5, 4, 3, 2, 1 };
} id[MAX] = { 1, 2, 3, 4, 5, 6, 7, 8 };
int main() {
for (int counter = 0; counter < MAX; counter++) {
cout << id[counter].x << ", " << id[counter].y << ", "<< id[counter].z << endl;
}
}