c++小知识
openfuture99
没什么好说的,我要学习。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
三元运算符
(关系表达式) ? 表达式1 : 表达式2; int x = 10; int y = 5; int z; 如果x大于y 则是true,将x赋值给z; 如果x不大于y 则是false,将y赋值给z; z = (x > y) ? x : y; System.out.println("x = " + x); 示例代码 #include<bits/stdc++.h> using namespace std; int main(){ int x,y,z; cin>>x>>原创 2020-11-03 11:15:38 · 141 阅读 · 0 评论 -
c++小数点保留
1.c++中小数点保留 #include<bits/stdc++> using namespace std; int main(){ float x=1.2630; //保留一位小数 cout<<fixed<<setprecision(1); cout<<x<<endl; //保留两位小数 cout<<fixed<<setprecision(2); cout<<x<<endl; //原创 2020-10-19 15:58:14 · 2543 阅读 · 0 评论
分享