fix(guide) Replace invalid prism code block names (#35961)
* fix: replace sh with shell fix replace terminal with shell fix replace node with js fix replace output with shell fix replace cs with csharp fix replace c++ with cpp fix replace c# with csharp fix replace javasctipt with js fix replace syntax with js fix replace unix with shell fix replace linux with shell fix replace java 8 with java fix replace swift4 with swift fix replace react.js with jsx fix replace javascriot with js fix replace javacsript with js fix replace c++ - with cpp fix: corrected various typos fix: replace Algorithm with nothing fix: replace xaml with xml fix: replace solidity with nothing fix: replace c++ with cpp fix: replace txt with shell fix: replace code with json and css fix: replace console with shell
This commit is contained in:
committed by
Oliver Eyton-Williams
parent
4b4762716c
commit
0a1eeea424
@@ -8,13 +8,13 @@ localeTitle: C ++数组
|
||||
|
||||
例如,包含5个称为数字的整数值的数组声明如下:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
int numbers [5];
|
||||
```
|
||||
|
||||
Initializiation:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
//Initialization with entries:
|
||||
int numbers [5] = {1, 2, 3, 4, 5};
|
||||
|
||||
@@ -34,7 +34,7 @@ Initializiation:
|
||||
可以通过引用它们在数组中的位置来访问数组中的元素。 (从0开始计数)。
|
||||
例:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
x = numbers[0]; // = 1. [0] == first position
|
||||
numbers[2] = 55; // Sets the third position (3) to the new number 55
|
||||
//numbers[] is now: {1, 2, 55, 4, 5}
|
||||
|
||||
@@ -37,7 +37,7 @@ update语句用于通过使用加法,减法,乘法或除法等简单操作
|
||||
|
||||
## 实现:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include <iostream>
|
||||
using namespace std; // Here we use the scope resolution operator to define the scope of the standar functions as std::
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ localeTitle: 输入和输出
|
||||
|
||||
“Hello World”程序使用`cout`打印“Hello World!”到控制台:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
@@ -30,24 +30,24 @@ localeTitle: 输入和输出
|
||||
|
||||
几乎所有东西都可以放入一个流:字符串,数字,变量,表达式等。这里有一些有效的流插入示例:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
// Notice we can use the number 42 and not the string "42".
|
||||
cout << "The meaning of life is " << 42 << endl;` // Output: The meaning of life is 42
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
string name = "Tim";
|
||||
cout << "Except for you, " << name << endl;`// Output: Except for you, Tim
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
string name = "Tim";
|
||||
cout << name;
|
||||
cout << " is a great guy!" << endl;`
|
||||
// Output: Tim is a great guy!
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
int a = 3;
|
||||
cout << a*2 + 18/a << endl;`// Output: 12
|
||||
```
|
||||
@@ -56,7 +56,7 @@ int a = 3;
|
||||
|
||||
C ++总是让_你_掌控,并且只完成你告诉它要做的事情。这有时会令人惊讶,如下例所示:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
string name = "Sarah";
|
||||
cout << "Good morning" << name << "how are you today? << endl;
|
||||
```
|
||||
@@ -65,7 +65,7 @@ string name = "Sarah";
|
||||
|
||||
换行也不会自己发生。你可能会认为这会在四行打印一个食谱:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
cout << "To make bread, you need:";
|
||||
cout << "* One egg";
|
||||
cout << "* One water";
|
||||
@@ -76,7 +76,7 @@ cout << "To make bread, you need:";
|
||||
|
||||
您可以通过在每行之后添加`endl`来解决此问题,因为如前所述, `endl`在换行流中插入换行符。但是,它也会强制冲洗缓冲区,这会让我们失去一点性能,因为我们可以一次打印所有的线条。因此,最好的方法是在行尾添加实际的换行符,并且最后只使用`endl` :
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
cout << "To make bread, you need:\n";
|
||||
cout << "* One egg\n";
|
||||
cout << "* One water\n";
|
||||
@@ -89,7 +89,7 @@ cout << "To make bread, you need:\n";
|
||||
|
||||
要从控制台中读取,您可以像使用`cout`一样使用_输入流_ `cin` ,但不要将内容放入`cin` ,而是“将它们取出”。以下程序从用户读取两个数字并将它们加在一起:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
@@ -112,7 +112,7 @@ cout << "To make bread, you need:\n";
|
||||
|
||||
提取运算符`<<`也可以链接。这是与上次相同的程序,但是以更简洁的方式编写:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ localeTitle: 地图
|
||||
|
||||
这是一个例子:
|
||||
|
||||
```c++
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
@@ -56,7 +56,7 @@ a => 10
|
||||
|
||||
使用插入成员函数插入数据。
|
||||
|
||||
```c++
|
||||
```cpp
|
||||
myMap.insert(make_pair("earth", 1));
|
||||
myMap.insert(make_pair("moon", 2));
|
||||
```
|
||||
@@ -69,7 +69,7 @@ myMap.insert(make_pair("earth", 1));
|
||||
|
||||
要访问地图元素,您必须为它创建迭代器。这是前面提到的一个例子。
|
||||
|
||||
```c++
|
||||
```cpp
|
||||
map<char, int>::iterator it;
|
||||
for(it=first.begin(); it!=first.end(); ++it){
|
||||
cout << it->first << " => " << it->second << '\n';
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
---
|
||||
title: IDE and Printing different text
|
||||
localeTitle: IDE和打印不同的文本
|
||||
---
|
||||
---
|
||||
title: IDE and Printing different text
|
||||
localeTitle: IDE和打印不同的文本
|
||||
---
|
||||
# IDE简介和打印不同的文本:
|
||||
|
||||
* 在上一篇文章中,有一些编程所需软件的下载链接。像这样的软件被称为IDE。 **IDE代表集成开发环境**
|
||||
|
||||
@@ -33,8 +34,7 @@ _问:尝试在Google上搜索IDE并在其上运行您的第一个程序。检
|
||||
```
|
||||
|
||||
上面的代码返回一个错误,因为在第2行,我们使用了冒号(:)而不是分号(;) 那么,让我们调试错误:
|
||||
上面的代码返回一个错误,因为在第2行,我们使用了冒号(:)而不是分号(;) 那么,让我们调试错误:
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
using namespace std ;
|
||||
int main()
|
||||
@@ -139,4 +139,4 @@ Hello World! I love freeCodeCamp!
|
||||
|
||||
`cpp (7!=5);` 评估结果为true
|
||||
|
||||
|
||||
[本文中使用的所有打印语句的总和。随意调整代码! :)](https://repl.it/L4ox)
|
||||
|
||||
@@ -10,7 +10,7 @@ while循环的一个关键点是循环可能永远不会运行。 当测试条
|
||||
|
||||
例:
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user