C++
来源:互联网 发布:php 数组的写法 编辑:程序博客网 时间:2024/05/21 17:08
vector初始化二维数组
// 另一种二维数组初始化方法vector<vector<int>> mat(2,vector<int>(3,1));// 其中2表示行数,3表示每行有多少个,1表示每个单位储存的值 int a[][3] = {{1,2,3},{4,5,6},{7,8,9}}; vector<vector<int> > mat(3); // 定义这个有多少行 for (int i=0; i<3; i++) { mat[i].resize(3); // 每一行的长度 } for (int i=0; i<3; i++) { for (int j=0; j<3; j++) { mat[i][j] = a[i][j]; } } mat = rotateMatrix(mat, 3);
使用ceil函数。ceil(x)返回的是大于x的最小整数。
如: ceil(10.5) == 11 ceil(-10.5) ==-10
pow() 函数用来求 x 的 y 次幂(次方),其原型为:
double pow(double x, double y);
排序函数sort() 要导入
#include <algorithm>vector<int> Asort(A.begin(), A.end());
取出字符串中的单个字符,string A = “asd”
A[0] = a
取绝对值
abs()
0 0
- c
- c
- c
- c
- C
- c
- c
- c
- C+
- c
- C
- c
- c
- c
- C
- C
- c
- C
- Window Navigator
- 发布Jar包到Maven中央仓库
- 设计模式之建造者模式
- acm第一战 新赛季的无名小辈
- 模拟strcpy与strncpy
- C++
- 如何在GDB中关联源代码
- 量化交易——传统技术分析平滑异同移动平均线MACD的原理及实现
- 上传本地代码到github
- solr5.5+tomcat8+jdk1.8配置
- AtCoder:AtCoder Group Contest(思维)
- mysql非法关机导致 错误 1067:进程意外终止
- Find a multiple (POJ
- Median of Two Sorted Arrays