.


:




:

































 

 

 

 





1. . , .

 

struct funds{

char* bank;

float fonds;

char* name;

float savef;

}stan={"", 1023.87, .., 123,45};

float sum (float, float);

void main(void){

printf (" .. %.2f .\n", sum(stan.fonds,stan.savef));

}

float sum(float x, float y){

return(x+y);

}

 

sum() , , , float.

 

2. , , .

modify(&stan.savef);

 

3. , . .

 

struct funds {...} stan={...};

void main(void){

float sum (struct funds*);

printf (" .. %.2f \n", sum(&stan));

}

float sum (stuct funds* money){

return(money->fonds+money->savef);

}

 

money funds. , &stan.

 

4. . .

 

struct funds {...}stans[2]={{...},{...}};

void main(void){

float sum (struct funds*);

printf (" %.2f \n", sum(stans));

}

float sum(struct funds* money){

float summ;

int i;

for (i=0, summ=0;i<2; i++, money++)

summ+=money->fonds+money->savef;

return (summ);

}

money <=> &stan[0]; money++, stan[1].

 

1. .

struct date { int day; int month;

int year; int yearday;}d={25,3,1999};

int date_tab[2][13]={{ 0,31,28,31,30,31,30,31,31,30,31,30,31},

{ 0,31,29,31,30,31,30,31,31,30,31,30,31}};

int day_of_year(struct date *pd) {

int i, day, l=0;

day = pd->day;

if(pd->year%4==0&&pd->year%100!=0||pd->year%400==0) // .

l=1;

for(i=0; i< pd->month; i++)

day+=date_tab[l][i];

return(day);

}

void main(void) {

d.yearday=day_of_year(&d); - .

printf(%d, d.yearday);

}

 

- , . , , .

. union. .

 

union simbl {

int digit;

double bigfl;

char letter;

};

union simbl fit, save[10], *pu.

 

bigfl (double 8 ), save[10] (10 x 8) .

?

fit.digit=23; (. 2)

fit.bigfl=2.0 (23 2.0)

fit.letter='a' (2.0 'a' 1)

pu=&fit; x=pu->digit;

.

++ . , :

 

union {

int digit;

double bigfl;

char letter;

};

 

; , .

digit=23;

bigfl=2.0

.

 

 

, .

typedef.

:

typedef int INT //INT- int

INT x, y;

 

typedef unsigned size_t;

size_t x, y; // unsigned

 

typedef char string[225];

string array; //char array[225];

 

1. typedef .

2. .

3. , #define.

 

real float:

typedef float real;

real x, y[5], *px;

, , .

typedef char* STRING //STRING- char.

STRING name, sign; //char*name,*sign;

 





:


: 2016-11-23; !; : 438 |


:

:

.
==> ...

2006 - | 1879 -


© 2015-2024 lektsii.org - -

: 0.01 .