C语言编写一个程序,提示用户输入两个日期,然后显示哪一个日期更早:

要求:Enter first date (mm/dd/yy):3/6/08
Enter second date (mm/dd/yy):5/17/07
5/17/07 is earlier than 3/6/08

#include "stdio.h"
int main()
{
    int mm,dd,yyyy,mm1,dd1,yyyy1;
     printf("Enter first date (mm/dd/yy):");
    scanf("%d/%d/%d",&mm,&dd,&yyyy);
    printf("Enter second date (mm/dd/yy):");
    scanf("%d/%d/%d",&mm1,&dd1,&yyyy1);
    if(yyyy>yyyy1)
      printf("%d/%d/%2.2d is earlier than %d/%d/%2.2d",mm1,dd1,yyyy1,mm,dd,yyyy);
    else if(yyyy=yyyy1)
       if(dd>dd1)
         printf("%d/%d/%2.2d is earlier than %d/%d/%2.2d",mm1,dd1,yyyy1,mm,dd,yyyy);
       else if(dd=dd1)
          if(mm>mm1)
             printf("%d/%d/%2.2d is earlier than %d/%d/%2.2d",mm1,dd1,yyyy1,mm,dd,yyyy);
          else
             printf("%d/%d/%2.2d is earlier than %d/%d/%2.2d",mm,dd,yyyy,mm1,dd1,yyyy1);
       else      
         printf("%d/%d/%2.2d is earlier than %d/%d/%2.2d",mm,dd,yyyy,mm1,dd1,yyyy1);
    else
      printf("%d/%d/%2.2d is earlier than %d/%d/%2.2d",mm,dd,yyyy,mm1,dd1,yyyy1);
     return 0;
}

C语言编写一个程序,提示用户输入两个日期,然后显示哪一个日期更早:_第1张图片

你可能感兴趣的:(C语言编写一个程序,提示用户输入两个日期,然后显示哪一个日期更早:)