题解 | #出生日期输入输出#
出生日期输入输出
https://www.nowcoder.com/practice/4a4a9dd1edb6453ba4a0432319200743
#include <stdio.h> int main() { int Id, year ; char month, date; scanf("%d", &Id); //利用 % 和 / 将数据分配给对应的变量 year = Id / 10000 % 10000; month = Id / 100 % 100; date = Id % 100; //将输出分为四种情况,对应的给月和日补零 if ((1990 <= year && year <= 2015) && (1 <= month && month <= 12) && (1 <= date && date <= 30)) { if (month < 10 && date >= 10) printf("year=%d\nmonth=0%d\ndate=%d\n", year, month, date); else if (month >= 10 && date < 10) printf("year=%d\nmonth=%d\ndate=0%d\n", year, month, date); else if (month < 10 && date < 10) printf("year=%d\nmonth=0%d\ndate=0%d\n", year, month, date); else printf("year=%d\nmonth=%d\ndate=%d\n", year, month, date); } else { printf("EOF!\n"); } return 0; }#C语言基础练习#