[刷题] PTA 03-树2 List Leaves】的更多相关文章

程序: 1 #include <stdio.h> 2 #define MaxTree 10 3 #define ElementType char 4 #define Tree int 5 #define Null -1 6 7 struct TreeNode { 8 ElementType Element; 9 Tree Left; 10 Tree Right; 11 } T1[MaxTree],T2[MaxTree]; 12 int N,check[MaxTree]; 13 14 Tree…
程序: 1 #include <stdio.h> 2 #include <queue> 3 #define MaxTree 20 4 #define Null -1 5 using namespace std; 6 7 struct TreeNode { 8 int Left; 9 int Right; 10 } T[MaxTree]; 11 int N,check[MaxTree]; 12 int count = 0; 13 14 int BuildTree(struct Tre…
1.  minimum-depth-of-binary-tree 题目描述 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 求二叉树的最小深度:   解题思路 递归遍历二叉树的每一个节点: (1)如果该节点为null,返回深度为0…
用栈实现树遍历 1 #include<stdio.h> 2 #include<string.h> 3 #define MAXSIZE 30 4 5 int Pre[MAXSIZE],In[MAXSIZE],Post[MAXSIZE]; 6 void solve(int preL,int inL,int postL,int n); 7 void outPut(int p[],int n); 8 9 int main(){ 10 int n,tmp,i,j = 0; 11 int to…
题目: 7-63 查验身份证 (15 分)  一个合法的身份证号码由17位地区.日期编号和顺序编号加1位校验码组成.校验码的计算规则如下: 首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}:然后将计算的和对11取模得到值Z:最后按照以下关系对应Z值与校验码M的值: Z:0 1 2 3 4 5 6 7 8 9 10 M:1 0 X 9 8 7 6 5 4 3 2 现在给定一些身份证号码,请你验证校验码的有效性,并输出有问题的号码.…
程序: 1 #include <stdio.h> 2 #include <stdlib.h> 3 typedef struct TreeNode *Tree; 4 struct TreeNode{ 5 int v; 6 Tree Left,Right; 7 int flag; 8 }; 9 Tree NewNode(int V){ 10 Tree T=(Tree)malloc(sizeof(struct TreeNode)); 11 T->v = V; 12 T->Le…
3. Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Examples: Given . Given . Given . Note that the answer must be a substring, "pwke" is a subsequence and not…
链表逆序 1 #include<iostream> 2 #include<stdio.h> 3 #include<algorithm> 4 using namespace std; 5 #define MAXSIZE 1000010 6 7 struct node { 8 int data; 9 int next; 10 } node[MAXSIZE]; 11 12 int List[MAXSIZE]; 13 int main() { 14 int First,n,k;…
程序: 1 #include<stdio.h> 2 #include<string.h> 3 #define N 81 4 5 int main() { 6 char ch[N],temp[N]; 7 int i,cnt,lng=0; 8 scanf("%d",&cnt); 9 gets(ch); 10 strcpy(temp,ch); 11 for(i=0; i<cnt; i++) { 12 gets(ch); 13 if(strlen(ch)&…
我的程序: 1 #include<stdio.h> 2 #include<string.h> 3 #define N 50 4 char token[]= {'+','-','*','/','(',')'}; 5 6 int istoken(char c) { 7 int i; 8 for(i=0; i<strlen(token); i++) { 9 if(token[i]==c) return 1; 10 } 11 return 0; 12 } 13 14 int main…