c++程序编译,完整程序

img

完全按照代码思路来写的,如有帮助,请采纳一下,谢谢。代码如下:

#include <iostream>
using namespace std;
int main()
{
    int y;
    for (y=2000;y<=2500;y++)
    {
        if(y%4 != 0)//S2
        {
            cout << y << "不是闰年" << endl;
            continue;
        }
        if(y%4==0 && y%100 != 0) //S3
        {
            cout << y << "是闰年"  << endl;
            continue;
        }
        if(y%100==0 && y%400 == 0) //S4
        {
            cout << y << "是闰年"  << endl;
            continue;
        }
        else
        {
            cout << y << "不是闰年"  << endl;
            continue;
        }
        cout << y << "不是闰年"  << endl;  //S5
    }
    return 0;
}



#include <stdio.h>

/*
2、输出2000~2050年间的所有闰年年份(能被4整除但不能被100整除或者能被400整除的年份即为闰年),
    每行输出5个年份,并计算一共有多少年。
*/
void main8(){
    int count =0;//保存闰年的总数
    int i;
    printf("闰年列表:\n");
    for(i=2000;i<=2050;i++){
        if((i % 4==0 && i % 100 !=0 ) || i % 400 == 0){
            printf("%d\t",i); 
            count++;
            //控制每行输出5个年份
            if(count % 5 == 0){
                printf("\n"); //换行 
            }
        }else{
             printf("不是闰年");
        } 
    }
    printf("\n共有%d个闰年\n",count); 
} 

你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)

#include<stdio.h>
int main()
{
    int y;
    y = 2000;
    do {
        if (y % 4 != 0) {
            printf("%d不是闰年\n",y);
        } else if (y % 100 != 0) {
            printf("%d是闰年\n",y);
        } else if (y % 400 == 0) {
            printf("%d是闰年\n",y);
        } else {
            printf("%d不是闰年\n",y);
        }
        y++;
    } while (y<=2500);
    return 0;
}


img