题解 | #出生日期输入输出#
出生日期输入输出
https://www.nowcoder.com/practice/4a4a9dd1edb6453ba4a0432319200743
#include <math.h> #include <stdio.h> int main() { int a; int q, w, e, r; scanf("%d", &a); q = a / 10000; w = a % 10000; e = w / 100; r = w % 100; if (e > 9 && r > 9) { printf("year=%d\nmonth=%d\ndate=%d", q, e, r); } else if (e <= 9 && r <= 9) { printf("year=%d\nmonth=0%d\ndate=0%d", q, e, r); } else if (e <= 9 && r > 9) { printf("year=%d\nmonth=0%d\ndate=%d", q, e, r); } else if (e > 9 && r <= 9) { printf("year=%d\nmonth=%d\ndate=0%d", q, e, r); } return 0; }