# include <stdio.h> int main() { int year1,year2,month1,month2,day1,day2,age; printf("请输入今天的日期,年月日用逗号分开。"); scanf("%d,%d,%d",&year1,&month1,&day1); printf("请输入你的生日,格式:年-月-日"); scanf("%d-%d-%d",&year2,&month2,&day2); age=year1-year2; printf("你今年%d岁了,你的生日是%d-%d-%d",age,year2,month2,day2); return 0; }
scanf()中的%d与%d之间的格式忘记了。
时间: 2024-12-28 11:37:42