s_tag.c
This commit is contained in:
parent
9749d1d31a
commit
467d7c540b
|
@ -0,0 +1,36 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define SIZE 3
|
||||
|
||||
struct s_tag {
|
||||
int a [SIZE];
|
||||
};
|
||||
|
||||
struct s_tag orange, lime, lemon;
|
||||
|
||||
struct s_tag twofold (struct s_tag s) {
|
||||
int j;
|
||||
for ( j = 0; j < SIZE; j++ )
|
||||
{
|
||||
s.a[j] *= 2;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i< SIZE; i++ )
|
||||
{
|
||||
lime.a[i] = 1;
|
||||
}
|
||||
lemon = twofold(lime);
|
||||
orange = lemon;
|
||||
for ( i = 0; i< SIZE; i++ )
|
||||
{
|
||||
printf("lime.a[%d]=%d\n", i, lime.a[i]);
|
||||
printf("lemon.a[%d]=%d\n", i, lemon.a[i]);
|
||||
printf("orange.a[%d]=%d\n", i, orange.a[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue