- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- void genderJudge(int num)
- {
- if (num % 2 == 1) {
- printf("No\t");
- }
- else {
- printf("Yes\t");
- }
- }
- int ageJudge(charchar *ID)
- {
- int year, month, day;
- int age;
- time_t t;
- struct tmtm * lt;
- time(&t);
- lt = localtime(&t);
- year = (ID[6] - '0') * 1000 + (ID[7] - '0') * 100 + (ID[8] - '0') * 10 + (ID[9] - '0');
- month = (ID[10] - '0') * 10 + (ID[11] - '0');
- day = (ID[12] - '0') * 10 + (ID[13] - '0');
- age = lt->tm_year + 1900 - year;
- if (((lt->tm_mon + 1) > month) && (lt->tm_mday > day)) {
- age--;
- }
- return age;
- }
- int main()
- {
- char ID[100][18];
- int N;
- int i;
- scanf("%d", &N);
- for (i = 0; i < N; i++) {
- scanf("%s", &ID[i]);
- }
- for (i = 0; i < N; i++) {
- genderJudge(ID[i][16]);
- printf("%d\n", ageJudge(&ID[i]));
- }
- system("pause");
- return 0;
- }
判断年龄和性别
最新推荐文章于 2024-02-27 19:26:02 发布