# Codeforces Round #183 (Div. 2) B. Days difference in Calendar

Source: Internet
Author: User

Question Link

Returns the number of days in two years.

Just set the template directly.

Calculate the number of days from two years to 0 years to 0 months, respectively, and subtract the absolute value.

Write template

`/*************************************** * *********************************> File Name: test. cpp> Author: yangshuo> Mail: 1115332213@qq.com> Created Time: on Wednesday 19, May 22, 2013 ******************************** **************************************** /# include <iostream> # include <stdio. h> # include <cmath> # include <algorithm> # include <string. h> using namespace std; const int days = 365; const int s [] = {, 31, 30, 31}; bool Isleap (int y) {if (y % 400 = 0 | y % 100 & y % 4 = 0) return 1; return 0;} int leap (int y) {if (! Y) return 0; return y/4-y/100 + y/400;} int calc (int day, int mon, int year) {int res = (year-1) * days + leap (year-1); for (int I = 1; I <mon; I ++) res + = s [I]; if (Isleap (year) & mon> 2) res ++; res + = day; return res;} int count_day (int da, int ma, int ya, int db, int mb, int yb) {int resa = calc (da, ma, ya); int resb = calc (db, mb, yb); return abs (resa-resb);} int main () {int ya, ma, da, yb, mb, db; while (scanf ("% d: % d", & ya, & ma, & da )! = EOF) {scanf ("% d: % d", & yb, & mb, & db); printf ("% d \ n", count_day (da, ma, ya, db, mb, yb);} return 0 ;}`
Related Keywords:

### Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.