- 博客(3)
- 问答 (2)
- 收藏
- 关注
原创 setprecision的两种用法
需要头文件 “precision”——“精度”,“set”——“设置” (一)保留n位有效数字 输入 #include <iostream> #include <iomanip> using namespace std; int main() { double x = 12.3; cout << x << endl; cout << setprecision(2) << x << endl; //不知道为什么只能忘比
2020-05-22 10:56:37
12750
4
原创 C++中exchange()函数的使用方法(例题)
C++函数exchange() 已知函数exchange(int *a,int *b),作用是交换a和b的值。 题目:将a与b的数值交换。代码如下。 #include <iostream> using namespace std; #include <iostream> using namespace std; int exchange(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; return 0;
2020-05-09 18:41:23
7784
转载 C++sort函数的使用说明(笔记)
C++中sort()函数的使用说明(个人笔记) (一)为什么要用c++标准库里的排序函数 Sort()函数是c++一种排序方法之一,学会了这种方法可解决使用的冒泡排序和选择排序所带来的执行效率不高的问题!因为它使用的排序方法是类似于快排的方法,时间复杂度为n*log2(n),执行效率较高! (二)c++标准库里的排序函数的使用方法 I)Sort函数包含在头文件为#include《algorithm>的c++标准库中。 II)Sort函数有三个参数: (1)第一个是要排序的数组的起始地址。 (2)第二个
2020-05-09 15:38:49
279
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人