C编写,输入一学生的生日(年:y0、月:m0、日:d0);输入当前的日期(年:y1、月:m1、日:d1);输出实足年龄.

来源:百度知道 编辑:UC知道 时间:2024/06/08 02:06:54
只是y1-y0就行了吗? 那题目给的m d 有什么意义呢?

这个就对了吧````
#include<stdio.h>

int main()
{ int y0,m0,d0;
int y1,m1,d1;
int age;
printf("Please input birthtime :");
scanf("%d,%d,%d",&y0,&m0,&d0);
printf("Please input the time now :");
scanf("%d,%d,%d",&y1,&m1,&d1);

if(y1<y0)
{printf("The data is error !");}
else
{age=y1-y0;
if(m1<m0)
age--;
else if(m1==m0)
{ if(d1<d0)
age--;}
}
printf("%d",age);
}

#include <stdio.h>
void main()
{
int y0,m0,d0;
int y1,m1,d1;
printf("please input the year month and date:");
scanf("%d%d%d",&y0,&m0,&d0);
printf("please input the time with now:");
scanf("%d%d%d",&y1,&m1,&d1);
printf("year with now is %dyear\t%dmonth\t%ddate\nthe input time is %dyear\t%dmonth\t%ddate\n",y1,m1,d1,y0,m0,d0);
printf("the age is %dold\n",y1-y0);
}

--------------------
怎么楼主用的是TC啊!我用的是VC6.0
C里本来就可以有中文!只是你的那个开发环境不允许!有机会可以试试VC哦!很不错的!

C编写,输入一学生的生日(年:y0、月:m0、日:d0);并输入当前的日期(年:y1、月:m1、日:d1);输出实足年龄. C编写,输入一学生的生日(年:y0、月:m0、日:d0);输入当前的日期(年:y1、月:m1、日:d1);输出实足年龄. 编写程序,输入一位学生的生日;输出该生的实际年龄。 编写一个C语言程序:输入三个学生三门课的成绩,计算每个学生的总分和平均成绩 C语言:编写一函数,输入一个十六进制数,输出一个对应的十进制数。 如何编写C程序:从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入 编写C语言;从键盘输入若干个学生的成绩计算出平均成绩,并输出低以平均分的成绩,用输入负数结束输入 ·编写C语言;从键盘输入若干个学生的成绩计算出平均成绩,并输出低以平均分的成绩,用输入负数结束输入? C语言题目:要求用户输入10个学生的考试成绩,并编写一个求平均值的函数,求这10个学生的平均成绩。 用c语言编写求输入20个数的平均值