08 2020 档案

摘要:#unique()函数存在于#include中 ##用法: unique(首地址,末地址) ###该函数会返回一个迭代器,该迭代器为第一个重复元素的地址, 该返回值减去数组名地址即为该函数中不重复元素数量 ##注意:该函数只是将重复的部分移到数组的后面 从而达到数组前面部分元素不重复 ##题目样例: 阅读全文
posted @ 2020-08-22 17:58 Auterman 编辑
摘要:#快速排序模板 #include #include using namespace std; int x[100000]; void qsort(int l, int r) { int i = l; int j = r; int mid = x[(l + r) / 2]; do { while (x 阅读全文
posted @ 2020-08-22 17:21 Auterman 编辑
摘要:#在STL库中(algorithm)存在nth_elememt()函数能对数组进行处理, 使得所求的第n小的数能够出现在a[n-1]中; ##用法:求函数中第n小的数, nth_element(数组名,数组名+n-1,数组名+数组元素总数); ##注意: 1.nth_element()是将整个数组进 阅读全文
posted @ 2020-08-22 15:16 Auterman 编辑
摘要:eg: #include #include #include<string.h> int x[10000]; //记录加工步骤 int order[30][30]; //记录每个物品的工序顺序 int cost[30][30]; //记录每个物品响应工序花费的时间 int work[30][1000 阅读全文
posted @ 2020-08-21 17:10 Auterman 编辑
摘要:#include<stdio.h>库中存在sprintf()函数能将不同类型的数据组合成字符数组 ##sprintf(destination,type,各种数据名) //destination为最终组合成的字符数组返回目标,type为组合的各类型数据的类型(与printf()中使用的相似) inst 阅读全文
posted @ 2020-08-19 17:37 Auterman 编辑
摘要:#在#include<stdio.h>中存在sscanf函数能将字符串中分成多个部分,分别转化为不同类型进行返回; ##sscanf(char *s,type,destination) //s为字符数组名,type为转化的种类(与scanf中的格式相同),destination为返回的目标 inst 阅读全文
posted @ 2020-08-19 16:29 Auterman 编辑
摘要:int isPrime(int n){ if(n==0||n==1) return 0; else{ for(int i=2;i<=sqrt(n);i++) \\无需特判n==2情况,because 当i==2时,sqrt(n)<2,循环不进行; { if(n%i==0) return 0; } } 阅读全文
posted @ 2020-08-19 11:19 Auterman 编辑
摘要:int gcd(int a ,int b){ if(a%b!=0){ return gcd(b,a%b); } else{ return b; } } 阅读全文
posted @ 2020-08-17 11:34 Auterman 编辑
摘要:原理:将一个数的幂分解为二进制进行处理,同一位幂只需处理一次,出去了两两相乘的重复操作; 呈上代码: int quickpow(int q,int n){ \\n为幂次,q为底数 int result=1; while(n){ \\n大于1时 \\位运算,当n二进制末位为1时 if(n&1){ re 阅读全文
posted @ 2020-08-16 11:46 Auterman 编辑
摘要:#1. >>为右移运算,末位去除,整体向右移动一位,首位补上原首位数字。 >若该数为正数(首位为0),则首位补0; >若该数为负数 (首位为1),则首位补1; #2. >>>为无符号右移运算,末位去除,整体向右移动一位,首位补上0; >无论该数的正负,其首位都补上0; eg: public clas 阅读全文
posted @ 2020-08-04 09:15 Auterman 编辑
摘要:#给整形int或long数据类型变量赋值时 2进制:0b加上二进制数 8进制:0加上八进制数 10进制:默认直接十进制数 16进制:0x加上十六进制数 阅读全文
posted @ 2020-08-02 15:05 Auterman 编辑

点击右上角即可分享
微信分享提示