a)
#define FC int x[FC][FC]={1,2,3, 4,5,6, 7,8,9};
int y[FC]={0, 0, 0};
main(){ int i,j; for(i=0;i<FC;i++) for(j=0;j<FC;j++) y[i]=y[i]+x[i][j]; for(i=0;i<FC;i++) printf("y[%d]: %d\n",i,y[i]); }
|
b)
void push(int); int pop(void); int notEmpty(void); int dato[100]; int tope=0; main(){ int x; push(111); if(notEmpty()){ x = pop(); printf("%d\n",x); } if(notEmpty()){ x = pop(); printf("%d\n",x); } } void push(int in){ dato[tope]=in; tope=tope+1; } int pop(void){ if(tope>0){ tope=tope-1; return dato[tope]; } } int notEmpty(void){ if(tope > 0) return 1; else return 0; }
|
c)
int buffer(int); main(){ int x; x = buffer(111); printf("%d\n",x); x = buffer(222); printf("%d\n",x); x = buffer(333); printf("%d\n",x); } int buffer(int in){ int dato[2]; int out; out = dato[1]; dato[1] = dato[0]; dato[0] = in; return out; }
|
d)
main(){ int x=987; int *y; y = &x; x = x/10; printf("%d\n",x); *y = *y%10; printf("%d\n",x); }
|
e)
struct s { int x; struct s *p; }; main(){ struct s a, b, *n; a.p = &b; a.x = 555; b.p = &a; b.x = 222; n = a.p->p; printf("%d\n",a.p->x); printf("%d\n",a.p->p->x); printf("%d\n",n->p->x); }
|