本文主要是介绍C语言计算日期A到日期B的天数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
思路:
C代码如下:
/*
Used to count how many days from day A to day B.
Notice: A<B
*/
#include<stdio.h>int totalYear(int year);
int parthYear(int year, int mounth, int day);int main(void)
{int yy, mm, dd;int total = 0;int date_A, date_B;int year_A, mounth_A, day_A;int year_B, mounth_B, day_B;printf("Enter day A such as yyyymmdd.\n");scanf("%d", &date_A);printf("Enter day B such as yyyymmdd.\n");scanf("%d", &date_B);if( date_A < date_B ){//分割年月日year_A = date_A / 10000;mounth_A = ( date_A / 100 ) % 100;day_A = date_A % 100;
这篇关于C语言计算日期A到日期B的天数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!