摘要: 二叉树的遍历 题型 此类题做法 1.定义节点 2.构造二叉树{ a.边界条件 b.建立新节点root 存入根节点数据(由后序或先序 c. k 遍历中序,找到相等的值 d. 得出左子树个数(中序的 ) e.返回左子树根节点地址,返回右子树根节点地址,return root; 3.层次遍历{ a.创建队 阅读全文
posted @ 2020-07-21 11:45 我来到,我看见 阅读(148) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; const int maxn=1000001; int prime[maxn],num=0; bool p[maxn]={0}; //找出素数 void findprime(int n){ for(int i=2;i<m 阅读全文
posted @ 2020-07-18 09:09 我来到,我看见 阅读(139) 评论(0) 推荐(0)
摘要: //之前是想这样写的,用sscanf和sprintf。但是部分错误,有两个点错误,一个运行时错误 PS:sprintf转成的是字符串不是单个字符吗?。因为是字符串转,所以忽略了如1000-0001=900等问题,还 超时了// 老老实实的用各位相加吧来自大佬的告诫:https://www.cnblo 阅读全文
posted @ 2020-07-18 08:40 我来到,我看见 阅读(182) 评论(0) 推荐(0)
摘要: #include<cstdio> #include<cstring> const int maxn=100010; const int MOD=1000000007; char str[maxn]; int leftnump[maxn]={0}; int main() { //gets(str); 阅读全文
posted @ 2020-07-18 08:04 我来到,我看见 阅读(124) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; int main() { int num[10]; for(int i=0;i<10;i++) { cin>>num[i]; } for(int i=1;i<10;i++) { if(num[i]>0){ cout<<i 阅读全文
posted @ 2020-07-17 01:32 我来到,我看见 阅读(101) 评论(0) 推荐(0)
摘要: #include<cstdio> #include<algorithm> using namespace std; struct moodcake{ double store; double sell; double price; }cake[1010]; bool cmp(moodcake a,m 阅读全文
posted @ 2020-07-16 14:12 我来到,我看见 阅读(128) 评论(0) 推荐(0)
摘要: #include<cstring> #include<cstdio> #include<algorithm> using namespace std; struct student{ char name[10]; char id[15]; int score; int location_number 阅读全文
posted @ 2020-07-15 02:39 我来到,我看见 阅读(90) 评论(0) 推荐(0)
摘要: 要点:1、数字存入数组。数p74 同类型题 B1002 写出这个数 #include<iostream> using namespace std; int main() { int a,b; int sum; cin>>a>>b; sum=a+b; int num[10]; //判断是否为正数 先输 阅读全文
posted @ 2020-07-13 14:42 我来到,我看见 阅读(105) 评论(0) 推荐(0)
摘要: a = str[i] - '0'什么意思: 如果str里面存放的是数字字符的话就是转成其数值类型 比如说str[i]是'1',其实ascii码值为0x31,而'0'的ascii码是0x30,用str[i]-'0'就得到了1 1、size()函数: c++中,在获取字符串长度时,size()函数与le 阅读全文
posted @ 2020-07-12 15:56 我来到,我看见 阅读(206) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; int main () { int a; long long b,c,d; cin>>a; int n[10][3]; for(int i=0;i<a;++i){ cin>> n[i][0]>>n[i][1]>>n[i] 阅读全文
posted @ 2020-07-12 13:11 我来到,我看见 阅读(74) 评论(0) 推荐(0)