要求输入一串不分隔的出生日期,将其中的年月日分别输出
#include<stdio.h>
int main()
{
int nian;
int yue;
int ri;
scanf("%4d%2d%2d",&nian,&yue,&ri);
printf("nian=%d\n",nian);
printf("yue=%02d\n",yue);
printf("ri=%02d\n",ri);
return 0;
}
20030609
nian=2003
yue=06
ri=09
--------------------------------
Process exited after 3.96 seconds with return value 0
Press any key to continue . . .
%4d:截取4位
%02d:截取两位,零补充