1-23

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
用c语言编写下面这题: 关于日期的结构定义如下: struct DateG{ int yy,mm,dd;}; 编写两个函数,一个计算自公元1年1月1日到指定的日期共经历了多少天。另一个是前一个函数的逆函数:由自公元1年1月1日历经指定的天数后的日期(返回年月日构成的日期)。 函数接口定义: struct DateG days2Date(int x);{//from:{1,1,1} + 100-->{1,4,11} int Days(DateG x);// {2,,4,11} return 465 from{1,1,1} 裁判测试程序样例: struct DateG{ int yy,mm,dd; }; char leapYear(int year);//闰年否 struct DateG _DateG(char *st);{//"1919-9-9"-->{1919,9,9} struct DateG Add(struct DateG x,int y);//{1919,9,9}+50-->{1919,10,29} char* Date2string(struct DateG x);//{1919,9,9}-->"1919-09-09" //以上为测试程序提供的测试用函数,略去不表, //以下两函数是必须自己完成的函数 struct DateG days2Date(int x);{//from:{1,1,1} + 100-->{1,4,11} int Days(struct DateG x);// {2,,4,11} return 465 from{1,1,1} int main(){ char st[12];scanf("%s",st); struct DateG d1=_DateG(st), d2=Add(d1,60*365); printf("%s\n",Date2string(d2)); d2=Add(d2,-1000); printf("%s\n",Date2string(d2)); d2=_DateG("2020-1-23"); printf("%.2f\n",(Days(d2)-Days(d1))/365.0); return 0; } /* 请在这里填写答案 */ 输入样例: 输入用-号分隔的出生年月日,系统确保测试数据的合法性 2001-1-1 输出样例: 共三行输出。分别是:60年(按365天计一年精确计算的)后的退休日期;退休前倒计时1000天的日期;武汉抗疫封城时(2020-1-23)的年龄(按每365天为一岁,保留2位小数)。 [2060-12-17] [2058-03-23] 19.07
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值