C++初步认识

Posted on 2021-07-03 11:04  Cookieboy  阅读(42)  评论(0)    收藏  举报

通用写框架开头

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6 
 7     system(“pause”)
 8     
 9     return 010 }
11 
12 //以上代码可以在写框架的时候都输入一遍

打印 hello world  

#include <iostream>
using namespace std;

int main()
{
    cout << "hello world" << endl; //cout 打印hello world 输入完成运行验证

    system(“pause”)
    
    return 0;
}

添加注释的方法为有两种形式注释

// 注释单行代码
/*注释多行代码*/      /**/ 在两个*好内的内容即为选择注释的内容

注释方案注释打印hello world 重新打印新的hello people

#include <iostream>
using namespace std;

int main()
{
    //cout << "hello world" << endl;  注释单行打印hello world
    
    cout << "hello people" << endl;

    system(“pause”)
    
    return 0;
}

变量 添加一个变量a并且打印

#include <iostream>
using namespace std;

int main()
{
    int a = 10; // 给变量a赋一个值
    
    cout << “a = ” << a << endl;  //打印结果为 a =10

    system(“pause”)
    
    return 0;
}