0 like 0 dislike
8.1k views
請設計一程式,讓使用者輸入一個數字代表西元年,程式會判斷該年是不是閏年。

 

範例輸入1

2000

範例輸出1

2000 year is a leap year

範例輸入2

1900

範例輸出2

1900 year is not a leap year
[Exercise] Coding (C) - asked in 作業 by (18k points)
ID: 12293 - Available when: Unlimited - Due to: Unlimited

reshown by | 8.1k views

201 Answers

0 like 0 dislike
Hidden content!
#include * ****** *

#include ** * * ** **



int main()

{
* ** * ****** * * year=0;
*** * ** ** ***** **** * * * * * ** * ** * * **
**** * ** * *** * ***** (year % 400 == 0)
** * * *
** * * * * * *** ** ** ** ** ** * * * ** *** * ** year is a leap year",year);
* ********** ** ** *
* ******* * * ** * * if(year%100==0)
** ** * * ** ****** **
*** ** *** * * *** *** *** ** * * * * * year is not a leap year",year);
* * ** *** *** * *** **
* ** ** *** ** * * * ** * if(year%4==0)
*** **** * * *** ** *
* ***** ** ** * *** * ** * ****** ***** *** * ** ** *** year is a leap ** ** * *
* * ** * ** ** ***** * * **
*** ** * * ** * ** * ** * * * year is not a leap * * ** ***



}
answered by (-136 points)
0 like 0 dislike
Hidden content!
** ** ** *** **

int main ()

{
* ** * *** * ** *** year;
* ** **** ***** ** *** ** * * *** *** * ****


* **** * *** * *** % 400 == 0)
* * * * *** * ** ** ****** * * * year is a leap ** ** *****
** ***** * ** if (year % 100 == 0)
* * **** * ** * *** * ** * ** ** year is a not leap ** ** ** ** *
***** ***** * * *** * if (year % 4 == 0)
** **** * ** * * * * ** *** * *** **** * year is a leap **** **
*** *** ** ****
******** ** * * ****** * * * * * year is not a leap * * *


* * * 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
***** * * * * * *



int * * )



{
******* ** *** *
*** * ***** ** * * *** ** * **** *** );


*** * **** *** * ( num % 4 != 0 )
** * ** *** ***
* * * * *** ** * * ** ** * is not a leap year ** **
* * * ** ****


** * ** ** **** *** if( num % * *** == 0 )
* * **** ***
* ***** **** * *** * * ** is a leap * * * **
**** * * ***** * * *


*** ****** *** if ( ( num % 4 == 0 ) ***** * ( num % 100 != 0 ) )
***** ** ***
* ** * *** ** ***** ** *** is not a ** ** *
*** **** * *




** *** * *** **** 0;

}
answered by (-24 points)
0 like 0 dislike
Hidden content!
** * * * * * *
* ** * )

{
*** * * * ***
***** ********** *** * * * * **** * * *** *
* ** * * ** * ** * % 4 != 0 )
* * * ** **** * year is a leap * *** * * * * *
* * * ** * ** * * % 4 == 0 ******* * year % 100 * *
* * * * * * *** year is not a * * **** **** **
* * * ** * % 400 != 0 ** * * * year % 100 *
* ** *** ** * * * *** *** is a leap ****** ****
* **** ** **** * ** * % 400 == 0 )
* ***** **** * * * ** ** year is not a leap ** ** * *
****** * ** 0;

}
answered by (43 points)
0 like 0 dislike
Hidden content!
#include * * * * ***

#include * * ** ** **** *





int main()

{
* *** * ** * *** ** * * * y;
** *** ** * * * **** * ** &y);
* * * **** * ** ** * ((y % 4==0) * * *** * * (y % 100!=0) * * * (y % 400==0))
* ********* ** *** * **** * * * * * * * * * * * ** * year is a leap * *** ***
**** * ** ** ** * **** ** *
*** * ** *** ** * *** ** ***** ** * ** * ** * ** year is not a leap *** * * **
*** ** ** ** * * * ** * *** ** * * ** 0;

}
answered by (-98 points)
0 like 0 dislike
Hidden content!
* * ** ** * * **
** * ** * * ** ** ****



int main()

{
* * * **** * * * y;
* * **** * ** * * ** **** ** * * **** *** * *


* * * * *** * ** * * (y % 400 == 0)
* * *** ** ** ** ***** * ** * * * * ** ** year is a leap ***** ** * * y);
** **** * ** ** if (y % 100 == 0)
* ** * *** ** * ****** ** *** * * **** *** year is not a leap ** * ** * y );
* ** ** ** * *** *** if (y % 4 == 0)
* *** **** * * ** **** * **** * * * ** year is a leap **** y);
******* ** ** ** ** ****
* ** *** ** * *** ** * ** **** * **** year is not a leap * ** **** y);


**** ***** * ** * 0;

}
answered by (180 points)
0 like 0 dislike
Hidden content!
* * * * *** * ***

int main ()

{
**** * * ** *** year;
** * * ***** * * * ** * * * ** * *


* * * ** * * * * (year % 4 != 0)
***** *** *** * * ** * * * ** year is a not leap ** * * *
* * ** * * * * ** ** if (year % 100 != 0)
***** ** * *** * * * **** * * ** * year is a leap * **** ** *
** * * ** ** **** * if ** % 400 != 0)
* * ** * * * *** ** * *** ** * * ** year is not a leap *** **** **
** ** * ** **** * *

* ***** *** * ** * * * *** * * * * * ** year is a leap * ** *** *** ***


* * 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
*** *** * * *

int main ()

{
* ** ** *** ** * * ** *
* * * **** * * * * * * *** *** * *


* * ** ** * * * *** ** % 4 != 0)
** * * * * * * * *** ** *** * * * **** year is a not leap * * * * *
** * * ** ***** ** if * ** % 100 != 0)
* *** * ***** * ** * *** * ** ** * * year is a leap ** ** ***
* * ** *** * if (year % 400 != 0)
** ****** * ******* * * * * * *** * year is not a leap ** * **
******* ** ** * ** if * % 400 = 0)
* ** * * *** * ** *** * *** ****** * * year is a leap * * * * * *


** 0;

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include * * * ** *

#include * ** * ***** * * ***





int main()

{
* * ** * * * ** **** *** y;
* * * *** * * * *** * ** * * &y);
** **** * * * * * * * ((y % 4==0) * * * *** (y % 100!==0) *** ** *** (y % 400 ==0))
* **** *** * **** ** ** *** ** ***** *** ** *** * ** year is a leap **** * ***** **
******** *** * * ** * *
* ** * **** *** * *** * ** * * * * ** * * * * * year is not a leap *** *
* * **** ** ** *** * * * *** **** * ** * ** * ** *** 0;

}
answered by (-98 points)
0 like 0 dislike
Hidden content!
** * * * * *
* * )

{
*** * * ** * **
* * ** * ***** *** **** * *
* * **** * ** * * % 4 != 0 )
** * ** ***** * * year is a leap ** * **
*** ** * * * * ** % 4 == 0 * **** ** year % 100 *
* ** * * * *** * * * ** * * year is not a * * * * * **** * **
* *** *** * * ** ** % 400 != 0 ******* * year % 100 * *
** *** ***** * ** * * *** * * is a leap *** ** ** *
* ** * * *** * ** % 400 == 0 )
* ** **** * ** year is not a leap * * * **
* *** ** * * 0;

}
answered by (43 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.179.135
©2016-2024

Related questions

0 like 0 dislike
152 answers
[Exercise] Coding (C) - asked Oct 5, 2016 in 作業 by Shun-Po (18k points)
ID: 12295 - Available when: Unlimited - Due to: Unlimited
| 6.2k views
0 like 0 dislike
131 answers
[Exercise] Coding (C) - asked Oct 5, 2016 in 作業 by Shun-Po (18k points)
ID: 12291 - Available when: Unlimited - Due to: Unlimited
| 5.5k views
1 like 0 dislike
48 answers
[Exercise] Essay (Open question) - asked Nov 2, 2016 in 作業 by Shun-Po (18k points)
ID: 16865 - Available when: Unlimited - Due to: Unlimited
| 2.6k views
0 like 0 dislike
76 answers
[Exercise] Coding (C) - asked Oct 19, 2016 in 作業 by Shun-Po (18k points)
ID: 14120 - Available when: Unlimited - Due to: Unlimited
| 3.5k views
0 like 0 dislike
91 answers
[Exercise] Coding (C) - asked Oct 13, 2016 in 作業 by Shun-Po (18k points)
ID: 13617 - Available when: Unlimited - Due to: Unlimited
| 4.2k views
12,783 questions
183,443 answers
172,219 comments
4,824 users