Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct profile {
- char idnumber[8]; /*学籍番号*/
- int age; /*年齢*/
- int year; /*生年月日*/
- int month;
- int day;
- int num;
- int height; /*身長*/
- int weight; /*体重*/
- double bmi; /*BMI*/
- } profile_t;
- void print_profile(struct profile x);
- profile_t input_profile(void);
- char *eto(int year);
- int main(void) {
- profile_t data;
- data = input_profile();
- print_profile(data);
- getchar();
- return 0;
- }
- void print_profile(profile_t x) {
- printf("%10s:%3d,%3d/%d/%d,", x.idnumber, x.age,x.year, x.month, x.day);
- printf("%s,", eto(x.year));
- printf("%3d,%3d,%.1f\n", x.height, x.weight, x.bmi);
- }
- profile_t input_profile(void) {
- struct profile x;
- printf("学籍番号:");
- scanf("%7s",x.idnumber);
- printf("年齢:");
- scanf("%d",&x.age);
- printf("生年月日\n");
- printf("年(西暦):");
- scanf("%d",&x.year);
- printf("月:");
- scanf("%d",&x.month);
- printf("日:");
- scanf("%d",&x.day);
- printf("身長:");
- scanf("%d",&x.height);
- printf("体重:");
- scanf("%d",&x.weight);
- x.bmi = (double)(100 * x.weight) / (x.height * x.height) * 100;
- getchar();
- return x;
- }
- char* eto_c[] = { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申",
- "酉", "戌", "亥" };
- char *eto(int year) {
- return eto_c[(year - 1900) % 12];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement