第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");
标签:语句,yy1,编写程序,mm,dd,mm1,yy,dd1,输入 来源: https://www.cnblogs.com/cjbsai/p/14613043.html