随笔分类 -  C/C++的基础知识

数字的标准写法
摘要:#include <bits/stdc++.h> using namespace std; #define ll long long char s[20],p[20]; int cnt; void solve(ll c){ if(c<0){ printf("-"); c=abs(c); } cnt = 0; while(c){//为0呢 s[cnt++] = char(c%10)+'0'; c/= 阅读全文

posted @ 2019-09-17 21:29 cltt 阅读(521) 评论(0) 推荐(0) 编辑

指针数组和二维数组指针
摘要:http://c.biancheng.net/view/2022.html int *p1[5] //指针数组 int (*p1[5])一样的 int (*p2)[5]//二维数组指针指针数组,每个元素都是指针,p1在32位环境下占4*5=20字节二维数组指针,是一个指针,它指向一个二维数组。p2占 阅读全文

posted @ 2019-09-11 10:08 cltt 阅读(651) 评论(0) 推荐(0) 编辑

随机函数
摘要:#include using namespace std; int main() { srand((unsigned)time(NULL)); //产生的随机数范围是0~65536, for(int i = 0; i < 10;i++ ) cout << rand() << '\n'; cout << endl; ... 阅读全文

posted @ 2019-04-09 21:40 cltt 阅读(440) 评论(0) 推荐(0) 编辑

重载问题
摘要:#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <utility> #include <vector> #in 阅读全文

posted @ 2019-04-08 21:01 cltt 阅读(108) 评论(0) 推荐(0) 编辑

输入
摘要:asd sa vdd dvaddvbfsv fb 时没反应了 阅读全文

posted @ 2019-03-27 17:13 cltt 阅读(428) 评论(0) 推荐(0) 编辑

异或
摘要:1 (1)使特定位翻转 2 3 假设有01111010,想使其低4位翻转,即1变为0,0变为1。可以将它与00001111进行∧运算,即 4 5 6 7 结果值的低4位正好是原数低4位的翻转。要使哪几位翻转就将与其∧运算的该几位置为1即可。这是因为原数中值为1的位与1进行∧运算得0,原数中的位值0与1进行∧运算的结果得1。 8 9 10 快速判断两个值是否相... 阅读全文

posted @ 2019-03-17 09:31 cltt 阅读(223) 评论(0) 推荐(0) 编辑

技巧
摘要:DEVc++ 在编译时要把之前的窗口都必须关掉才可以再次编译 阅读全文

posted @ 2019-03-08 15:19 cltt 阅读(89) 评论(0) 推荐(0) 编辑

二进制减法
摘要:每一位不够减了,就借2,借的是上一位的,那么到了上一位时,还要还-1 阅读全文

posted @ 2018-12-28 21:09 cltt 阅读(1852) 评论(0) 推荐(0) 编辑

jichu
摘要:第 76 题 请编写函数 fun,其功能时:计算并输出当 x=1e-6); return sum; } 请编写函数 fun,该函数的功能是:删去一维数组中所有相同的数,使之只剩 一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。 int f(int *a,int n) { for(int i=0;i<n;i++){ ... 阅读全文

posted @ 2018-11-23 22:44 cltt 阅读(271) 评论(0) 推荐(0) 编辑

scanf
摘要:1 int a,b; 2 long c; 3 void fun(int a,int b,long *c) 4 {*c=(b%10)*1000+(a%10)*100+(b/10)*10+a/10;} 5 int main() 6 { 7 scanf("%d%d",&a,&b); 8 long *p=&c; 9 fun(a,b,p); 10 prin... 阅读全文

posted @ 2018-11-23 21:15 cltt 阅读(195) 评论(0) 推荐(0) 编辑

指针
摘要:1 p:指针 2 p->num 和(*p).num 等价 阅读全文

posted @ 2018-11-15 22:45 cltt 阅读(187) 评论(0) 推荐(0) 编辑

引用
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 typedef long long ll; 11 const int inf=0x3f3f3f3f; 12 t... 阅读全文

posted @ 2018-11-15 20:20 cltt 阅读(209) 评论(0) 推荐(0) 编辑

int long long 的范围
摘要:unsigned int 0~4294967295 (10位数,4e9) int -2147483648~2147483647 (10位数,2e9 2^31 - 1) long long: -9223372036854775808~9223372036854775807 (19位数, 9e18 )  阅读全文

posted @ 2018-08-30 12:48 cltt 阅读(146) 评论(0) 推荐(0) 编辑

优先级顺序
摘要:1 https://baike.baidu.com/item/%E8%BF%90%E7%AE%97%E7%AC%A6%E4%BC%98%E5%85%88%E7%BA%A7/4752611?fr=aladdin * / % + - 阅读全文

posted @ 2018-08-27 23:34 cltt 阅读(229) 评论(0) 推荐(0) 编辑

误区
摘要:int n; int main() { scanf("%d",&n); cout>b == a/(2^b) &&还具有短路的功能,即如果第一个表达式为false,则不再计算第二个表达式 int a[5]; char c ='d'; for(int i=0;i<4;i++) a[i]=i; for(int i=0;i<... 阅读全文

posted @ 2018-08-16 11:50 cltt 阅读(175) 评论(0) 推荐(0) 编辑

二进制
摘要:1 如果 x>0&&x&(x-1)==0 那么x为2的指数幂 0&(-1)==0 阅读全文

posted @ 2018-08-12 20:41 cltt 阅读(150) 评论(0) 推荐(0) 编辑

变量
摘要:1 局部数组:没有默认值,如果声明的时候不定义,则会出现随机数(undefined);如果声明的长度与赋值长度不相等,则有,声明的长度>赋值长度,后面用0补足,声明的长度>赋值长度,发生编译错误; 2 3 4 5 全局数组:声明时不赋值,默认值为0 6 在所有函数(包括主函数)之外定义的变量称为“全局变量”。 阅读全文

posted @ 2018-07-30 10:24 cltt 阅读(128) 评论(0) 推荐(0) 编辑

子串!=子序列
摘要:1 例如:一个字符串 awbcdewgh 2 3 他的子串: awbc、awbcd、awbcde ...很多个子串 ,但是都是连续在一起 。//substring 4 5 他的子序列:(subsequence ) abc 、abcd、 abcde ... 很多个子序列 ,但是子序列中的字符在字符串中不一定是连在一起的,而是删除其中若干个, 但是子序列一定是单调的(即字符之间ASC... 阅读全文

posted @ 2018-07-28 11:54 cltt 阅读(218) 评论(0) 推荐(0) 编辑

%%%%%%%%
摘要:1 1 //强制类型转换 2 2 // https://blog.csdn.net/chaipp0607/article/details/54834954 3 4 double x; 5 int y1,y2; 6 scanf("%lf",&x); 7 y1=int(x); 8 y2=int(round(x)); 9 pri... 阅读全文

posted @ 2018-07-20 15:02 cltt 阅读(1281) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

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