求助c语言高手

这个补位,还是忽略数值不是很懂,求助大神,谢谢啦
2024-11-22 21:50:01
推荐回答(1个)
回答(1):

代码文本:

#include "stdio.h"

int main(int argc,char *argv[]){  

char a[19];

int y,m,d;

printf("Please enter the id number...\n");

if(scanf("%18[0-9xX]",a)!=1){

printf("Input error, exit...\n");

return 0;

}printf("%s\n",a);

sscanf(a+6,"%4d%2d%2d",&y,&m,&d);

printf("The result is:\n%-6d%6.02d%6.02d%6d\n",y,m,d,y+m+d);

return 0;

}