c语言求年龄函数 c语言计算实足年龄
用C语言编写一个计算自己年龄的函数。
struct Date{
成都创新互联公司是专业的洛扎网站建设公司,洛扎接单;提供成都网站制作、做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行洛扎网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
int year;
int month;
int day;
};
Date * fun(Date *date){
Date today;
today.year = 2013;
today.month = 7;
today.day = 1;
Date age;
age.year = today.year - date-year;
age.month = today.month - date-month;
age.day = today.day - date-day;
return age;
}
int main(){
Date me;
me.year = 1980;
me.month = 6;
me.day = 12;
Date * age = fun(me);
printf("%d%d%d",age-year,age-month,age-day);
return 0;
}
如何用C语言编写输入出生年月,求出年龄的代码
#includestadio.h
main()
{ int year,year1,month,month1,day,day1,age;
printf("请输入您的生日:");
scanf("%d %d %d",year,month,day);
printf("请输入当前日期:");
scanf("%d %d %d",year1,month1,day1);
if(year1==year)
age=0;
else
{age=year1-year;
if(month1month||(month1==monthday1day))
age=age-1;
}
printf("您的年龄是:%d",age);
}
计算年龄的C语言程序
#include
stdio.h
void
main()
{
int
y1,m1,d1,y0,m0,d0,y,m,d;
printf("请输入当前日期\n");
printf("y1=");
scanf("%d",y1);
printf("m1=");
scanf("%d",m1);
printf("d1=");
scanf("%d",d1);
printf("请输入学生的生日\n");
printf("y0=");
scanf("%d",y0);
printf("m0=");
scanf("%d",m0);
printf("d0=");
scanf("%d",d0);
y=y1-y0;
m=m1-m0;
d=d1-d0;
printf("该学生的年龄为%d
%d
%d",y,m,d);
}
已经成功运行
祝你学业有成
文章名称:c语言求年龄函数 c语言计算实足年龄
本文链接:http://myzitong.com/article/dopdcph.html