题目一:
#include <stdio.h>
void main()
{
int i, j = 0;
for (i = 1000; i <= 1999; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
{
printf("%d ", i); j++;
if (j % 3 == 0);
printf("\n");
}
}
}
题目二:
#include<stdio.h>
int main()
{
int year = 0;
int month = 0;
printf("请输入年份:");
scanf_s("%d", &year);
printf("请输入月份:");
scanf_s("%d", &month);
switch (month)
{
case 1:
printf("一月有31天");
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
printf("二月有28天");
}
else printf("二月有29天");
break;
case 3:
printf("三月有31天");
break;
case 4:
printf("四月有30天");
break;
case 5:
printf("五月有31天");
break;
case 6:
printf("六月有30天");
break;
case 7:
printf("七月有31天");
break;
case 8:
printf("八月有31天");
break;
case 9:
printf("九月有30天");
break;
case 10:
printf("十月有31天");
break;
case 11:
printf("十一月有30天");
break;
case 12:
printf("十二月有31天");
break;
}
return 0;
}
题目三:
#include<stdio.h>
int main()
{
for (int i = 100; i <= 999; i++)
{
int m = 0;
for (int n = 1; n < i / 2 + 1; n++)
{
if (i % n == 0)
{
m = m + n;
}
if (i == m)printf("%d", i);
}
}
return 0;
}
题目四:
#include<stdio.h>
int main()
{
double sum = 0, i = 1;
for(;i<=100000;i++)
{
sum=sum+1/i;
}
printf("%f", sum);
return 0;
}