1 日期显示
题目内容:
编写一个程序, 接收用户录入的日期信息并且将其显示出来. 其中, 输入日期的形式为月/日/年(mm/dd/yy), 输出日期的形式为年月日(yy.mm.dd)。
#include<stdio.h>
int main()
{
int yea,mon,day;
printf("Enter a date (mm/dd/yy):\n");
scanf("%d/%d/%d",&mon,&day,&yea);
printf("You entered the date: %04d.%02d.%02d\n",yea,mon,day);
return 0;
}
输入
Enter a date (mm/dd/yy):
12/03/2015↙
输出
You entered the date: 2015.12.03
2 产品信息格式化
题目内容:
编写一个程序, 对用户录入的产品信息进行格式化。
以下为程序的运行结果示例:
Enter item number:
385↙
Enter unit price:
12.5↙
Enter purchase date (mm/dd/yy):
12/03/2015↙
输出
Item Unit Purchase
385 $ 12.50 12032015
#include<stdi