摘要: 非0整数(正数、负数)进行bool转换,均为true。0的强制类型转换为bool为false bool强制类型,如果为float转bool,如果a!=0.0,则为true,否则为true;如果为str转bool,若str='',str中为空,则bool(str)的内容为false,否则为true,空 阅读全文
posted @ 2024-04-17 18:13 writecodechangeworld 阅读(23) 评论(0) 推荐(0)
摘要: 基本数据类型 number int money=6600 float discount=1.2 boolen isok=true isok=false string s='sssss' s="ssssss" ps:单引号与双引号成对出现,不可以混合使用 可以单引号嵌套双引号,互相嵌套 list(列表 阅读全文
posted @ 2024-04-16 22:45 writecodechangeworld 阅读(10) 评论(0) 推荐(0)
摘要: 1.algorithm 实现a+b 字符串的加法 注意事项对进位的控制 int carry=0 i=a.size()-1;j=b.size()-1; while(i>=0;j>=0){ string res=""; num=carry+a[i]-'0'+b[i]-'0';//-'0'是为了变为cha 阅读全文
posted @ 2024-03-27 23:51 writecodechangeworld 阅读(19) 评论(0) 推荐(0)
摘要: 关于c语言中sin/cos的用法 若想输出30度的sin30 写法sin(303.1415926/180)对此控制输出用printf("%.2f",)即可保留两位小数 *reverse函数使用时需要加#include 注意!!!!reverse翻转string时,reverse(str.begin( 阅读全文
posted @ 2024-03-22 09:06 writecodechangeworld 阅读(12) 评论(0) 推荐(0)
摘要: 求最大公约数 0与任何数字的最大公约数都是非0数字。 int gcd(int lhs,int rhs){//默认lhs>=rhs if (rhs==0){ return lhs; } return gcd(rhs,lhs%rhs);//辗转相除 } 冒泡排序 for(int i=0;i<n;++i) 阅读全文
posted @ 2024-03-20 20:11 writecodechangeworld 阅读(21) 评论(0) 推荐(0)
摘要: ky29潜在朋友 用map来记录喜欢图书的人数,map[b]++,key值自增。 it=map1.find(vec[i]) 若(it->second-1)>0表示除了自己还有别人喜欢这本书,即为朋友则输出it->second -1; 写ky220对称矩阵有感 先设定一个布尔变量,当矩阵元素不对称时, 阅读全文
posted @ 2024-03-19 21:50 writecodechangeworld 阅读(14) 评论(0) 推荐(0)