close
閏年小知識
公曆

現時世界普遍採用的公曆是格列高里曆,它的前身是儒略曆。根據儒略曆的規定,每4年有1個閏年,閏年為366日,其餘3年(稱為平年)各有365日。公元年數能被4除得盡的是閏年。儒略曆1年平均長365.25日,比實際公轉週期的 365.2422日長11分14秒,即每400年約長3日。
教皇格列高里十三世於1582年宣佈改曆,改變置閏規則。公元年數被4除盡的是閏年,但如被100除得盡而被400除不盡的則不是閏年。這樣的做法可在400年中減少3個閏年。在格列高里曆下,400年中有97個閏年(每年366 日)及303個平年(每年365日),所以每年平均長365.2425日,與公轉週期的365.2422日十分接近。

原發表者:jefferylee
/**************************************************************
* 西元=民國+1911 *
* 1.西元末兩位不為00,且為4的倍數,則該年為閏年 *
* 2.西元末兩位為00,則可被400整除者,則該年為閏年,否則為平年 *
**************************************************************/
#include<iostream>

using namespace std;
void main(void)
{
 int year;
 cout<<"請輸入西元年數: ";
 cin>>year;
 if((year%4)&&!(year%100))
   cout<<"該年為閏年"<<endl;
 else
 {
   if(!(year%400))
     cout<<"該年為閏年"<<endl;
   else
   cout<<"該年不為閏年"<<endl;

 }
}

原發表者:小綱
#include<iostream>

using namespace std;



void main(void) {

  int year;

  cout<<"請輸入西元年數: ";

  cin>>year;

  if((!(year%4)&&(year%100))||!(year%400))

     cout<<"該年為閏年"<<endl;

  else

     cout<<"該年不為閏年"<<endl;  

}

原發表者:rclrn
//5.輸入西元年數,判斷其是否為閏年。
//compiled by Borland C++ Builder 6
#include <iostream>
using namespace std;

int main()
{
 int year = 0;
 cout << "Enter a year: ";
 cin >> year;

 cout << year << " is "
      << (((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) ? "" : "not ")
      << "a leap year."
      << endl;

 system("pause");
 return 0;
}

原發表者:andyeric
/*輸入西元年數, 判斷其是否為閏年.*/

#include <stdio.h>
#include <conio.h>

int main()
{
   int in_year;
   printf("請輸入西元年數 = ");
   scanf("%d",&in_year);
   
   if((in_year%4==0)&&(in_year/100!=0)||(in_year%400==0))
   printf("%d 為閏年",in_year);
   else
   printf("%d 為平年",in_year);
   
   getch();
   return 0;
}

原發表者:zoe
#include <stdio.h>

main()
{
       int year;

       scanf("%d", &year);

       if ( year % 400 == 0 )                  /* 逢四百潤 */
               printf("%d是閏年\n", year);
       else if ( year % 100 == 0 )             /* 逢百年不潤 */
               printf("%d非閏年\n", year);
       else if ( year % 4 == 0 )               /* 4 年潤一次 */
               printf("%d是閏年\n", year);
       else
               printf("%d非閏年\n", year);
}

原發表者:kulisa
//輸入西元判斷是否為閏年
#include "iostream.h"
void main(){
int year;
cout<<"input year:"; cin>>year;
if(!(year%400)||((year%100)&&!(year%4)))
 cout<<"yes!";
}

原發表者:s831590234
#include<iostream>
using namespace std;

void main(void) {

 int year;

 cout<<"請輸入西元年數: ";
 cin>>year;
 if((!(year%4)&&(year%100))||!(year%400))
   cout<<"此年為閏年"<<endl;
 else
   cout<<"此年不為閏年"<<endl; 
} 


在此感謝當年在數位高手(NBP)分享的朋友,本人將資料彙整於此並盡量將當初發表者名稱註記。
arrow
arrow
    全站熱搜

    NBPBlog 發表在 痞客邦 留言(2) 人氣()