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 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <iostream>
#include <cstdlib>
using namespace std;
struct ABC{
int n;
char c;
double a[3];
};
void get( int & n, char & c, double a[3], const ABC & x ){
n = x.n;
c = x.c;
for (int i = 0; i < 3; i++){
a[i] = x.a[i];
}
}
void get( int n[], char c[], double a[][3], const ABC x[], int elements ){
for (int i = 0; i < elements; i++){
get(n, c, a, x);
}
}
int main(){
ABC x = {number, m, {1, 2, 3}};
ABC xx[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}}
};
int n;
char c;
int a[] = {};
int n1 [4] = {};
char c1 [4] = {};
double a3 [4] [3] = {};
int elements = 3;
get( n, c, a, x );
get(n1, c1, a3, xx, elements);
return 0;
}
|