C++第一天

简单的C++程序实例

#include<iostream>

using namespace std;

int main()

{

    cout<<"hello!"<<endl;

    cout<<"welcom to C++!"<<endl;

    return 0;

}

输出:

Hello!

welcome to C++!

 

#include <iostream>

using namdespace std;

int main()

{

    int year;

    bool isLeapYear;

    cout<<"enter the year:";

    cin>>year;

    isLeapYear=((year%4==0&&year%100!==0)||(year%400==0));

    if(isLeapYear)

{

    cout<<year<<"is a leap year"<<endl;

}

else

{
    cout<<year<<"is not a leap year"<<endl;

}

return 0;

}

 

posted @ 2023-04-10 21:08  涨涨涨张  阅读(9)  评论(0编辑  收藏  举报