#include <stdio.h>

/* 年月日*/
struct Birth
{
    char year[20];
    char yue[20];
    char day[20];
};
/* 记录页*/
struct Record
{
    struct Birth birth;
    char mingzhi[100];
    char iphone[100];
    char qqhao[100];
    char email[100];
};
int count = 0;
Record record[10] = {0};

/*添加用户*/
void tianjia_record();
/*显示一个用户*/
void xianshi_record(int index);
/*显示通讯录*/
void showmany_record()
{
    if (0 != count) {
        for (int i = 0; i < count; xianshi_record(i), ++i);
        return;
    }
    printf("没有用户,添加后查询\n");
}

void xianshi_record(int index)
{
    Record* n = record + index;
    printf("姓名    =%s\n", n->mingzhi);
    printf("手机号  =%s\n", n->iphone);
    printf("QQ号码  =%s\n", n->qqhao);
    printf("邮箱    =%s\n", n->email);
    printf("生日    =%s年%s月%s日\n\n", n->birth.year, n->birth.yue, n->birth.day);
}

void tianjia_record()
{
    Record* n = record + count++;
    printf(" 姓名  =");
    scanf("%s", n->mingzhi);
    printf(" 手机号=");
    scanf("%s", n->iphone);
    printf(" 邮箱  =");
    scanf("%s", n->email);
    printf(" QQ号码=");
    scanf("%s", n->qqhao);
    printf(" 出生年=");
    scanf("%s", n->birth.year);
    printf(" 出生月=");
    scanf("%s", n->birth.yue);
    printf(" 出生日=");
    scanf("%s", n->birth.day);
    printf("\n");
}

int main()
{
    for (int b;;) {
        /*操作输入*/
        printf("输入操作码(1-新添加,2-通讯录,3-查编号,4-退出)\n");
        scanf("%d", &b);
        if (b == 1) {
            /*添加操作*/
            tianjia_record();
        }
        else if (b == 2) {
            printf("通讯录列表...\n");
            showmany_record();
        }
        else if (b == 3) {
            printf("需要查询的用户编号(0开始):");
            int c; scanf("%d", &c);
            if (c >= count) {
                printf("该编号的用户不存在\n\n");
                continue;
            }
            /*显示指定编号用户*/
            xianshi_record(c);
        }
        else{
            printf("程序结束\n");
            break;
        }
    };
    return 0;
}