C + + brush question--2710: function---leap year judgment

Source: Internet
Author: User

Writing FunctionsIs_leapyeardetermines whether the argument is a leap year and returns if the argument is a leap year1, if not a leap year returns0. in the main function input year, the calling functionIs_leapyearto determine whether it is a leap year, depending on the outcomethe output of the year February has several days.
/* All rights reserved. * File name: Test.cpp * Chen Dani * Completion date: May 21, 2015 * Version number: v1.0 */#include <iostream>using namespace Std;int is_leapyear (in T m);   Declaration of a leap year function int main () {int year; cin>>year; if (Is_leapyear (year) ==1)    cout<<29<<endl; Else    cout<<28<<endl; return 0;} int is_leapyear (int m) {    if (m%4==0&&m%100!=0) | | m%400==0)        return 1;    else        return 0;}
Experience: Speed up the pace, added up, and continue to work!!

C + + brush question--2710: function---leap year judgment

Related Article

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.