C-language printing leap year 1000--2000

Source: Internet
Author: User

Leap Year Judgment method:

1. Years that can be divisible by 400;

2. Year that can be divisible by 4 but not divisible by 100 at the same time.

A leap year is one that satisfies either of these conditions.

Here are three different forms

The procedure is as follows:

One:

#include < stdio . h >

int Main ()

{

int =

for (M = <= ++ )

{if (M % == 0)

{if (M % == 0)

{if(M%= =0)

N = 1;

Else n=0;

        }

Else n=1;

     }

else =

if(n) printf ("%d", M,count+ +);

   }

if % == 0) printf ( );p rintf ( "\ncount=%d" ,count);

return 0;

}

Two:

#include < stdio . h >

int Main ()

{

int m,n,count=0;

for (M = <= ++ )

{if (M % == 0)

{if (M % != 0) printf ( "%d " ++ );

if (M % == 0)

printf ("%d", M,count+ +);

}printf ("\ncount=%d", count);

return 0;

}

Three:

#include < stdio . h >

int Main ()

{

int m,count=0;

for(m=1000;m<=2000;m+ +)

  {

  if(M%4==0&&m% -!=0||m% -==0) printf ("%d", M,count++);

  }

printf ("\ncount=%d", count);

return 0;

}

This is known as the "four Years a leap, a century does not leap, 400 years to leap" Leap year algorithm program. But for a large number of years, if the year can be divisible by 3200, and divisible by 172800 is a leap, this program is not considered.


This article is from the "Materfer" blog, make sure to keep this source http://10741357.blog.51cto.com/10731357/1698504

C-language printing leap year 1000--2000

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.