1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
struct ABC{
unsigned n;
char c;
double a[3];
};
void show( const ABC & x ){
cout << "{" << x.n << ", ";
cout<< "\'" << x.c << "\', {";
for (int i = 0; i < 3; i++){
if (i == 2){
cout << x.a[i] << "";
break;
}
cout << x.a[i] << ", ";
}
cout << "}}";
}
void show( const ABC arr[], unsigned elements ){
for (int i = 0; i < elements; i++){
show(arr[i]) << endl;
}
}
int main (){
ABC structArr[4] = {
{123, ‘A’, {1.1, 1.2, 1.3}},
{234, ‘B’, {2.1, 2.2, 2.3}},
{345, ‘C’, {3.1, 3.2, 3.3}},
{456, ‘D’, {4.1, 4.2, 4.3}}
};
show(structArr, 4);
return 0;
}
|