Created
May 15, 2017 01:17
-
-
Save koluku/71ff64d636fee7fde28df4a584b87dee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--- int 型スタックを実現する構造体 ---*/ | |
typedef struct{ | |
int max; /* スタックの容量 */ | |
int ptr; /* スタックポインタ */ | |
char name[20];/* 氏名 */ | |
int height; /* 身長 */ | |
double vision; /* 視力 */ | |
} PhysCheck; | |
/*--- スタックにデータをプッシュ ---*/ | |
int Push(PhysCheck *s, char name, int height, double vision) { | |
if (s->ptr >= s->max) return -1; /* スタック満杯 */ | |
s->name[s->ptr] = name; | |
s->height[s->ptr] = height; | |
s->vision[s->ptr] = vision; | |
s->ptr++; | |
return 0; | |
} | |
/*--- スタックからデータをポップ ---*/ | |
int Pop(PhysCheck *s, char *name, int *height, double *vision){ | |
if (s->ptr <= 0) return -1; /* スタックは空 */ | |
s->ptr--; | |
*name = s->name[s->ptr]; | |
*height = s->height[s->ptr]; | |
*vision = s->vision[s->ptr]; | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment