求闰年(填空题) Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description
程序功能:求出公元m年至n年的所有闰年并输出(m和n的值从键盘输入),同时统计出闰年个数并输出,要求每行输出5个数据。 要求: 1.程序有5处需要填空,请用正确的语句替代程序代码中的横线。 2.提交正确的源程序。
#include <stdio.h> #include <stdio.h> int main() { Int i,rn=0,year,m,n,t; scanf("%d %d",,); if(m>n){t=m;;n=t;} for(year=m;year<=n;) { if(year@&&______________||year@00) { rn++; printf("m",year); if(rn%5==0) printf("\n"); } } printf("\n%d\n",rn); return 0; } Input
输入起始年和截至年(用空格分隔)。 Output
输出起始年和截至年之间的闰年,输出的每个数据占6位宽度(m 格式)。 Sample Input
1949 2019 Sample Output
1952 1956 1960 1964 1968 1972 1976 1980 1984 1988 1992 1996 2000 2004 2008 2012 2016 17 Hint
#include <stdio.h> int main(void) { int n,m; int i,j; int a[1001]; int cn=1; scanf("%d %d",&n,&m); for(i=n;i<=m;i++) { if((i%2==1)&&(i%3==0)&&(i%5!=0)) { a[cn++]=i; } } for(j=1;j<cn;j++) { printf("%d ",a[j]); if(j%8==0) { printf("\n"); } } return 0; }