随笔分类 - 语法
个人模板
摘要:Math & DP & Data structure & Graph & Geometry & Game 表演者: magicat 💕 nannan 目录 Math & DP & Data structure & Graph & Geometry & GameHead快读1快读2快读3模板1模板2
阅读全文
某次作业
摘要:只做了后两个,PPT哪一页我找不到了 /* c++ 1.对自加运算符重载的函数体(ppt里可以找到)进行四合一的操作 2.日期自增考虑实际输出 3.用友元重载前缀自加运算符 */ #include<iostream> using namespace std; int day[]={0,31,28,3
阅读全文
UVA1589 象棋 Xiangqi题解
摘要:这题考察我们的大脑体力,非常难调,我花了3.5小时,要是在区域赛里做着题,我碰都不碰,没有大样例非常难受。 分析如下: 中国象棋,见百度百科 就是考虑当前情况下将军是不是已经给将死了 考虑: 飞将 将军吃掉了红色棋子的情况 马脚问题 将军只能在一定的区域内移动 注意边界情况 善用工具来debug,我
阅读全文
某次作业
摘要:#include<iostream> #include<string> using namespace std; class Teacher { public: void set2(string a,string b,string c,string d,string e,string f); voi
阅读全文
友元函数求两点的距离
摘要:#include<iostream> #include<cmath> using namespace std; class point { friend double get(point,point); public: point(int a,int b) { x=a,y=b; } private:
阅读全文
STL算法总结
摘要:// AC one more times #include<iostream> #include<string> #include<map> #include<queue> #include<random> #include<time.h> #include<algorithm> #include<
阅读全文
类实现明天的日期
摘要:C++作业 #include <iostream> #include <algorithm> using namespace std; class TDate { public: TDate(int y,int m,int d):year(y),month(m),day(d) {} TDate(){
阅读全文
C++复数的类+-*/
摘要:构造函数实现复数的加减乘除 实部虚部为0的时候有点小问题 上一次的在下面 #include<iostream> #include<complex> using namespace std; class Complex { public: Complex(){ r=0;i=0;} //void ini
阅读全文
vector 及被认为是移位运算符而编译错误
摘要:vector菜鸟编程链接 STL容器的可变长度数组,头文件#include<vector> 1. vector<int>v(N,i) 建立一个可变长度数组v,内部元素类型为int,最开始有N个元素,都初始化为i。可省略i(默认值为0),也可以把(N,i)省略,此时这个数组的长度就是0.也可以用dou
阅读全文
自用(曾经看到不懂的代码)三目运算符 二分 returnx>=y; typedef #define vector 共用体union
摘要:三目运算符: 提供了一种表达简单 if-else 语句的简写方法。该运算符由问号(?)和冒号(:)组成,其格式如下: 表达式 ? 表达式 : 表达式 ; if(x>50) x++; else x--; x>50?x++:x--; 两种写法作用相等 二分: int mid= (left + right
阅读全文
memset在此作用域尚未声明,初始化int数组和对其他值初始化错误,洛谷P1618 三连击(升级版)
摘要:memset初始化int数组 memset(a1,0,sizeof(a1));//数组初始化为0 memset(a1,127,sizeof(a1));//数组初始化为一个很大且接近int类型上限的正数 memset(a1,128,sizeof(a1));//数组初始化为很小且接近int类型下限的负数
阅读全文
cin读取数字时遇到字符的总结——C++ primer plus 代码引起思考, 为什么输入q使得程序结束,
摘要:1 // lotto.cpp -- probability of winning 2 #include <iostream> 3 // Note: some implementations require double instead of long double 4 long double pro
阅读全文
浙公网安备 33010602011771号