代码:
#include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { int day,month,year; do{ printf("Enter a date(mm/dd/yyyy):"); scanf("%d/%d/%d",&month,&day,&year); printf("You entered the date %4d%02d%02d ",year,month,day); }while(year!=9999); return 0; }
输出:
Enter a date(mm/dd/yyyy):2/17/2011 You entered the date 20110217 Enter a date(mm/dd/yyyy):3/3/2019 You entered the date 20190303 Enter a date(mm/dd/yyyy):2020/6/9 You entered the date 9202006 Enter a date(mm/dd/yyyy):6/9/2020 You entered the date 20200609
--2020年6月9日--