![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++基础
ifreewolf99
这个作者很懒,什么都没留下…
展开
-
C++二叉树结点实现和初始化
二叉树结点通常使用struct结构体来定义:#include<iostream>using namespace std;struct TreeNode{ int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}};int main(){ TreeNode *root = new TreeNo原创 2020-09-18 22:49:59 · 2460 阅读 · 0 评论 -
C++中double保留n位小数
方法一:c语言中的方法#include<cstdio>printf("%.3f", a);方法二:C++中iomanip头文件#include<iomanip>double x = 123.123456789;cout << setiosflags(ios::fixed) << setprecision(3) << std::fixed << x << endl;cout<< setio原创 2020-09-18 21:45:50 · 10317 阅读 · 0 评论 -
c++基础:双冒号的使用
#include<iostream>using namespace std;int atk = 200;int main(){ int atk = 100; cout<<"局部atk = " << atk << endl; # 100 // 双冒号 作用域运算符 :: 全局作用域, 冒号前没有任何值,表示全局作用域, // std::cout 表示std作用域中的cout函数 cout&l.原创 2020-09-16 23:23:57 · 1957 阅读 · 0 评论