2020年2月6日
摘要: qsort()括号里面有4个参数 第一个参数是将要排序的数组名array 第二个参数是将要排序的数量n 第三个参数是每个要排序的参数的大小sizeof(array[0]) 第四个参数是自己写一个比较函数cmp 前面三个参数比较通俗易懂,主要是最后一个cmp函数重写 1:数字的qsort排序 a:从大 阅读全文
posted @ 2020-02-06 15:33 Aldrich_2020 阅读(712) 评论(0) 推荐(0) 编辑
  2019年3月11日
摘要: 1 //任意输入字符串,可以包括任何字符。 2 //1、统计字符串中各个字符的个数,包括空格 3 //2、去除单词中间多余的空格,包括字符串首尾空格 4 //3、在数字和字母中间插入字符 5 //4、将单词提取出来,并统计单词的字母个数 6 //5、将字母排序,字母大小写的,保持原来先后顺序 7 //6、将指定的字符串替换为另一个字符串 8 #include 9 #includ... 阅读全文
posted @ 2019-03-11 15:27 Aldrich_2020 阅读(321) 评论(0) 推荐(0) 编辑
  2019年2月20日
摘要: 方法一:《算法笔记》以及《王道机试指南》都是先取出sqrt(n)范围内的质数,然后遍历整除,求得相关质因数。 方法二:方法绝妙,参看代码,一开始无法理解为什么不需要判断后面的是不是素数,其实一开始整除2,就将所有相关的倍数除尽了。 阅读全文
posted @ 2019-02-20 23:25 Aldrich_2020 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 bool isN(char c){//判断该字符是否是数字 4 if(c>='0'&&c='a'&&c='A'&&c<='Z')) 9 return true; 10 else return false; 11 } 12 int main(){ 13 char c[110]; 14 while(g... 阅读全文
posted @ 2019-02-20 22:28 Aldrich_2020 阅读(519) 评论(0) 推荐(0) 编辑
  2019年2月14日
摘要: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes 阅读全文
posted @ 2019-02-14 15:30 Aldrich_2020 阅读(238) 评论(0) 推荐(0) 编辑
  2019年2月13日
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 FILE fp; 5 char str[1000]; 6 int k=0; 7 char ch; 8 while((ch=getchar())!=EOF){ 9 str[k++]=ch; 10 } 11 str[k]='\ 阅读全文
posted @ 2019-02-13 10:08 Aldrich_2020 阅读(1376) 评论(0) 推荐(0) 编辑
  2019年2月12日
摘要: 动态规划的数塔问题 最大连续子序列和 最长不下降子序列(LIS) 阅读全文
posted @ 2019-02-12 15:55 Aldrich_2020 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 struct node{ 5 int data; 6 node *lchild; 7 node *rchild; 8 }; 9 int pre[32],in[32]; 10 node *create(int preL,int preR,int... 阅读全文
posted @ 2019-02-12 14:45 Aldrich_2020 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou 阅读全文
posted @ 2019-02-12 11:19 Aldrich_2020 阅读(144) 评论(0) 推荐(0) 编辑
  2019年2月8日
摘要: 题目描述 编写一个程序,将输入字符串中的字符按如下规则排序(一个测试用例可能包含多组数据,请注意处理)。 规则 1 :英文字母从 A 到 Z 排列,不区分大小写。 如,输入: Type 输出: epTy 规则 2 :同一个英文字母的大小写同时存在时,按照输入顺序排列。 如,输入: BabA 输出:  阅读全文
posted @ 2019-02-08 10:50 Aldrich_2020 阅读(382) 评论(0) 推荐(0) 编辑