07 2020 档案

摘要:二叉树的遍历 题型 此类题做法 1.定义节点 2.构造二叉树{ a.边界条件 b.建立新节点root 存入根节点数据(由后序或先序 c. k 遍历中序,找到相等的值 d. 得出左子树个数(中序的 ) e.返回左子树根节点地址,返回右子树根节点地址,return root; 3.层次遍历{ a.创建队 阅读全文
posted @ 2020-07-21 11:45 我来到,我看见 阅读(149) 评论(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 我来到,我看见 阅读(149) 评论(0) 推荐(0)
摘要://之前是想这样写的,用sscanf和sprintf。但是部分错误,有两个点错误,一个运行时错误 PS:sprintf转成的是字符串不是单个字符吗?。因为是字符串转,所以忽略了如1000-0001=900等问题,还 超时了// 老老实实的用各位相加吧来自大佬的告诫:https://www.cnblo 阅读全文
posted @ 2020-07-18 08:40 我来到,我看见 阅读(189) 评论(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 我来到,我看见 阅读(127) 评论(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 我来到,我看见 阅读(104) 评论(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 我来到,我看见 阅读(129) 评论(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 我来到,我看见 阅读(106) 评论(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 我来到,我看见 阅读(215) 评论(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 我来到,我看见 阅读(78) 评论(0) 推荐(0)
摘要:#include<iostream> #include<cstdio> using namespace std; int main() { int a,b; cin>>a>>b; int c; c=(b-a); if(c%100>=50) c+1; //这里错误,应先换算成正常单位在进行+1的四舍五 阅读全文
posted @ 2020-07-12 13:10 我来到,我看见 阅读(100) 评论(0) 推荐(0)
摘要://结果部分正确 #include<iostream> using namespace std; typedef long long ll; ll px(ll a,ll b) { ll p=0; if(a%10==b) { p=p*10+b; a=a/10; } return p; } int ma 阅读全文
posted @ 2020-07-12 12:38 我来到,我看见 阅读(86) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; int main() { int n; char c; int row; cin>>n>>c; for(int i=1;i<=n;i++) { row=i; if(row==1||row==n) { for(int j= 阅读全文
posted @ 2020-07-12 01:27 我来到,我看见 阅读(167) 评论(0) 推荐(0)
摘要:错误答案1:#include<iostream> using namespace std; const int maxn=100000; int a[maxn]={0}; int main(){ int n,id,sco,k,j; cin>>n; for(int i=0;i<n;i++){ a[id 阅读全文
posted @ 2020-07-12 00:12 我来到,我看见 阅读(151) 评论(0) 推荐(0)
摘要:1001 害死人不偿命的(3n+1)猜想 写后总结:数字与字母相乘,乘法不能省略;注意局部变量的位置;别光写算法,把"输出"忘记写.这是一个部分正确的,原因是什么?#include<iostream> using namespace std; int main() { //int max=1000; 阅读全文
posted @ 2020-07-11 21:45 我来到,我看见 阅读(103) 评论(0) 推荐(0)
摘要:一、算法原理 冒泡算法的本质是交换--数组元素间的对比交换+数组元素递增比较(确保最后一个肯定是最大的)+趟数用递增减少次序。 二、程序 #include<iostream> using namespace std; int main() { int n[5]={3,1,4,5,2}; for(in 阅读全文
posted @ 2020-07-11 03:59 我来到,我看见 阅读(298) 评论(0) 推荐(0)
摘要:#include<stdio.h>这个叫头文件 math.h数学函数 string.h跟字符串有关的函数-strlen、strcmp、strcpy、strcat、memset 等价写法 如cstdio,把“.h”换成 “c”开头 c/c++混合写法,命名.cpp。选择语言C++ 或G++ #incl 阅读全文
posted @ 2020-07-06 02:31 我来到,我看见 阅读(185) 评论(0) 推荐(0)