国产成人AV一区二区三区在线_国产成人精品无码免费看_国产成人无码无卡在线观看_国产精品成人A区在线观看_国产日韩精品欧美一区_国产亚洲精品自在久久蜜TV_久草热久草热线频97精品_久久久噜噜噜久久中文福利_久久婷婷五月综合色国产免费观看_日日狠狠久久偷偷色综合0,九一桃色在线观看,久久97精品久久久久久久不卡,国产成人精品亚洲精品

在main函數(shù)中調(diào)用日期輸入函數(shù)輸入當(dāng)天的日期和生日,計(jì)算今天到下次生日中間隔多少天(

訪客2025-01-22 18:35:521

你要用什么語言(java/c/c++/python等都有main但都沒有自帶的日期輸入函數(shù)

以下是C的參考

#include <stdio.h>#include <time.h>time_t gettime(int y, int m, int d) //轉(zhuǎn)換格式{struct tm tm_;time_t t;tm_.tm_year= y - 1900; //年tm_.tm_mon = m - 1; //月tm_.tm_mday= d; //日tm_.tm_hour= 0; //時(shí)tm_.tm_min = 0; //分tm_.tm_sec = 0; //秒tm_.tm_isdst = 0;//夏令時(shí)t = mktime(&tm_); //生成時(shí)間return t;}int main(){time_t t, t1, dif;int y, m, d,m1,d1;printf("請(qǐng)輸入當(dāng)前年月日(用-號(hào)分隔):");scanf("%d-%d-%d", &y, &m, &d);printf("請(qǐng)輸入你日年月(用-號(hào)分隔):");scanf("%d-%d",&m1, &d1);t = gettime(y,m,d);if (m>m1 || (m==m1 && d>d1) )//今年生日已過t1=gettime(y+1,m1,d1);elset1=gettime(y,m1,d1);dif = difftime(t1, t); //與輸入時(shí)間差,秒數(shù)printf("今天到下次生日還有%d天", (int)(dif / (3600 * 24)));return 0;}

文章評(píng)論