1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <stdio.h> #include <string.h> int main() { char parent[20],a[20],b[20],c[20],d[20],e[20],f[20]; printf("这是一个测试父母性别的程序\n******* made by王柏森 *******\n"); printf("请问您想测父亲|母亲的性别?\n请输入father or mother: "); scanf_s("%19s", &parent,(unsigned)sizeof(parent)); if (strcmp(parent, "father") == 0) { printf("请问您吃早饭了吗\n"); scanf_s("%19s", &a, (unsigned)sizeof(parent)); printf("请问您吃中饭了吗\n"); scanf_s("%19s", &b, (unsigned)sizeof(parent)); printf("请问您吃晚饭了吗\n"); scanf_s("%19s", &c, (unsigned)sizeof(parent)); printf("您父亲的性别是 男"); } else if (strcmp(parent, "mother") == 0) { printf("请问您吃早饭了吗\n"); scanf_s("%19s", &d, (unsigned)sizeof(parent)); printf("请问您吃中饭了吗\n"); scanf_s("%19s", &e, (unsigned)sizeof(parent)); printf("请问您吃晚饭了吗\n"); scanf_s("%19s", &f, (unsigned)sizeof(parent)); printf("您母亲的性别是 女"); } else { printf("输入错误,请输入father或mother"); } return 0;
}
|