第5章选择语句9、编写程序提示用户输入两个日期,哪个更早

    int mm, dd, yy, mm1, dd1, yy1;
    printf("Enter first date (mm/dd/yy): ");
    scanf("%d /%d /%d", &mm1, &dd1, &yy1);

    printf("Enter second date (mm/dd/yy): ");
    scanf("%d /%d /%d", &mm, &dd, &yy);

    if(yy1 < yy)
        printf("%d/%d/%d is earlier than %d/%d/%d", mm1, dd1, yy1, mm, dd, yy);
    else if(yy < yy1)
        printf("%d/%d/%d is earlier than %d/%d/%d", mm, dd, yy, mm1, dd1, yy1);
    else if(mm1 < mm)
        printf("%d/%d/%d is earlier than %d/%d/%d", mm1, dd1, yy1, mm, dd, yy);
    else if(mm < mm1)
        printf("%d/%d/%d is earlier than %d/%d/%d", mm, dd, yy, mm1, dd1, yy1);
    else if(dd1 < dd)
        printf("%d/%d/%d is earlier than %d/%d/%d", mm1, dd1, yy1, mm, dd, yy);
    else if(dd < dd1)
        printf("%d/%d/%d is earlier than %d/%d/%d", mm, dd, yy, mm1, dd1, yy1);
    else
        printf("same");

上一篇:B - 迎娶公主(bfs+状压)


下一篇:(c++)leetcode.200——岛屿数量