Unverified Commit 7b6e0cb9 authored by Shuhao Zhang's avatar Shuhao Zhang Committed by GitHub
Browse files

Merge pull request #1744 from xingjiapeng/master

📖 Update helloworld.md
parents ff26e2fb 8973cbf3
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ IDE 操作较为简单,一般入门玩家会选用 IDE 来编写代码。在
xcode-select --install
```

#### NOI Linux
#### Linux

使用 `g++ -v` 来检查是否安装过 `g++`

@@ -34,10 +34,14 @@ sudo apt update && sudo apt install g++

熟练之后也有玩家会使用更灵活的命令行来编译代码,这样就不依赖 IDE 了,而是使用自己熟悉的文本编辑器编写代码。

g++ 是 C++ 语言的编译器,C 语言的编译器为 gcc。

## 第一行代码

通过这样一个示例程序来展开 C++ 入门之旅吧~

C++ 语言

```c++
#include <cstdio>  // 引用头文件

@@ -46,3 +50,25 @@ int main() { // 定义 main 函数
  return 0;                 // 返回 0,结束 main 函数
}
```

```c++
#include <iostream>  // 引用头文件

using namespace std;

int main() {               // 定义 main 函数
  cout << "Hello, world!"  // 输出 Hello, world!
      return 0;            // 返回 0,结束 main 函数
}
```

C 语言

```c
#include <stdio.h>  // 引用头文件

int main() {                // 定义 main 函数
  printf("Hello, world!");  // 输出 Hello, world!
  return 0;                 // 返回 0,结束 main 函数
}
```