1 Star 0 Fork 0

上玄/c++

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
welcome.cpp 929 Bytes
一键复制 编辑 原始数据 按行查看 历史
上玄 提交于 2023-08-08 02:29 +08:00 . update welcome.cpp.
//引入头文件
#include <stdio.h>
#include <iostream>
#define PI 3.14
//预处理宏定义常量,无需数据类型,一般大写
using namespace std;
//引入命名空间
//空值函数
void welcome()
{
//输出。结束行
cout << "请输入你的姓名:" << endl;
//定义变量
char name[11];
//输入变量
cin >> name;
//变量+字符串输出
cout << "你好," << name << endl;
//string ts = "你好,";
//string names = ts + name;
/*printf函数只能输出C语言内置数据类型,不包括string
string输出可以用c_str()函数*/
printf("你好,%s\n",name);
}
int main()
{
//申明函数
int datatype();
//输出你好
printf("你好");
welcome();
//常量,浮点型
const float Pi = 3.1415926;
cout << "PI= " << Pi << endl;
//调用函数
datatype();
//等待键盘输入
cin.get();
cin.get();
return 0;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/skyvippower/studyc.git
git@gitee.com:skyvippower/studyc.git
skyvippower
studyc
c++
master

搜索帮助