- 博客(6)
- 收藏
- 关注
原创 [算法笔记]C++标准模板库(STL)
1.vector1)定义vector<typename> name;变长数组name[size],size可以根据需要变化vector<int> name;vector<char> name;vector<double> name;vector<vector<int> >name;//typename如果也是v...
2019-07-28 21:31:07 231
原创 [算法笔记]Hash散列
一.散列1.整数散列把输入的数作为数组下标进行来对这个数的性质进行统计。以空间换时间eg:给出N个正整数,再给出M个正整数,问M中的每个数是否在N中出现过思路:以空间换时间,设定bool类型数组hashTable[100010],其中hashTable[x]==true表示正整数x在N个正整数中出现过,false表示没有出现过,在读入N个正整数的时候就可以进行预处理,即读入的数为x,令ha...
2019-07-23 21:21:45 162
原创 [算法笔记]数学问题
1.最大公约数&&最小公倍数欧几里得算法(辗转相除)gcd(a,b)=gcd(b,a%b)int gcd(int a,int b){ if(b==0)return a; else return gcd(b,a%b);}得到a,b的最大公约数d之后,a,b的最小公倍数即ab/d。2.分数四则运算1.分数的表示结构体表示定义分子分母struct Fr...
2019-07-22 21:42:17 257
原创 [算法笔记]大整数运算
1.大整数存储大整数又称高精度整数,用基本数据类型无法村存储其精度的整数,用数组存储定义int型数组d[1000],数组中每一位存储整数的每一位,整数高位存储在数组的高位,整数的低位存储在数组的低位运算的时候从低位到高位进行枚举,整数按字符串类型进行读入(读入的时候是逆序的 需要反转一下)struct bign { int d[1000]; int len; bign() { m...
2019-07-21 20:03:40 258
原创 [PAT-A 1101]Quick Sort
1101 Quick Sort (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pi...
2019-07-06 20:10:53 140
原创 [PAT-A 1029]Media
Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is...
2019-07-03 21:28:58 134
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人