31 条题解
-
0
输出:Hello, World! 是C++ 和很多编程语言的最简单、基本的程序。
现在,我们来写一下这个程序。
此程序需要用到输入输出的头文件:
#include <iostream>
还有下面语句:
using namespace std;
最重要的是下面的输出语句:
cout
此语句是 C++ 中最基本的输出语句,此语句后面要加上 << 输出流语句就可以输出,下面展示了 cout 的使用样例:
#include <iostream> using namespace std; int main() { cout <<1; // cout 语句可以直接输出数字 return 0; }
此代码可以输出一个数字 1 ,可是我们要输出的东西不是数字,怎么办?
很简单,用双引号将我们要输出的东西引起来就行了,使用样例:
#include <iostream> using namespace std; int main() { cout <<"!@#%&@#@^%sadfD3w@#%D3DFDsgtyUJbF54$%"; return 0; }
此代码可以输出一段乱七八糟的东西。
目前为止,cout 的用法已经讲完了(其实还有很多,只是这里用不到了)
于是,初级代码如下:
#include <iostream> using namespace std; int main() { cout <<"Hello,World!"; return 0; }
信息
- ID
- 72
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 17248
- 已通过
- 4495
- 上传者