2019年3月14日
摘要: 本篇文章给大家带来的内容是关于C++中string&char *&char[]之间如何转换(示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。 一、string转char*。 主要有三种方法可以将str转换为char*类型,分别是:data(); c_str(); copy(); 阅读全文
posted @ 2019-03-14 08:51 tomctx 阅读(2883) 评论(1) 推荐(1) 编辑
  2016年3月10日
摘要: Java多线程基础:进程和线程之由来 在前面,已经介绍了Java的基础知识,现在我们来讨论一点稍微难一点的问题:Java并发编程。当然,Java并发编程涉及到很多方面的内容,不是一朝一夕就能够融会贯通使用的,需要在实践中不断积累。由于并发肯定涉及到多线程,因此在进入并发编程主题之前,我们先来了解一下 阅读全文
posted @ 2016-03-10 15:27 tomctx 阅读(189) 评论(0) 推荐(0) 编辑
  2012年10月13日
摘要: http://www.cnblogs.com/hebeiDGL/ 阅读全文
posted @ 2012-10-13 23:24 tomctx 阅读(69) 评论(0) 推荐(0) 编辑
  2012年5月1日
摘要: //《算法》P103 1 template <typename Type> 2 void greedySelector(int n, Type s[], Type f[], bool A[]) 3 { 4 A[1] = true; 5 int j = 1; 6 for(int i = 2; i <= n; ++ i){ 7 if(f[j] <= s[i]){ 8 A[i] = true; 9 j = i;10 }11 else12 A[i] = fal... 阅读全文
posted @ 2012-05-01 15:57 tomctx 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <cstdlib> 3 #include<cstring> 4 using namespace std; 5 6 int max(int a, int b) 7 { 8 return (a >= b)? a : b; 9 }10 11 int min(int a, int b)12 {13 return (a < b)? a : b;14 }15 16 void knapsack(int v[], int w[], int c, int n, int m[][20])17 {18 阅读全文
posted @ 2012-05-01 15:48 tomctx 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 《算法》P49 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<string.h> 4 //int m[102][102], s[102][102]; 5 void MatrixChain(int *p, int n, int m[][102], int s[][102]) 6 { 7 for(int i = 1; i <= n; i ++) 8 m[i][i] = 0; 9 for(int r = 2; r <= n; r ++){10 for(int i = 1; i <= n 阅读全文
posted @ 2012-05-01 11:08 tomctx 阅读(216) 评论(0) 推荐(0) 编辑
  2012年4月30日
摘要: #include <iostream>#include <cstdlib>#include<cstring>using namespace std;template<typename Type>int partition(Type a[], int low, int high){ //返回基准元素的最终位置 a[0] = a[low];//辅助空间a[0] Type key = a[low];//用子表的第一个记录作为枢纽记录 while(low < high){ while(low < high && a[high] 阅读全文
posted @ 2012-04-30 13:51 tomctx 阅读(224) 评论(0) 推荐(0) 编辑
  2012年4月29日
摘要: #include <iostream>#include <cstdlib>#include<cstring>using namespace std;#define LQ( a, b) ((a) <= (b))#define EQ(a, b) ((a) == (b))#define LT(a, b) ((a) < (b))void Merge(int a[], int *d, int i, int m, int n){ //将有序的a[i...m],有序的a[m+1...n]归并为有序的d[i...n]; int j, k, l; for(j = 阅读全文
posted @ 2012-04-29 15:53 tomctx 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 对已排列好的非递减数组进行查找。(1)非递归算法:#include <iostream>#include<cstdlib>using namespace std;template <typename Type>int binarySearch(Type a[], const Type &x, int n){ int low = 0; int high = n - 1; int middle; while(low <= high){ middle = (low + high) / 2; if(x == a[middle]) return mid. 阅读全文
posted @ 2012-04-29 13:29 tomctx 阅读(191) 评论(0) 推荐(0) 编辑
  2012年4月20日
摘要: 《算法设计与分析》P56 1 #include<iostream> 2 #include<cstdlib> 3 using namespace std; 4 5 void LCSLength(int m, int n, char *x, char *y, int c[][10], int b[][10]) //定义函数时,**c,**b不会用 6 { 7 int i, j; 8 for(i = 1; i <= m; ++i){ 9 c[i][0] = 0;10 b[i][0] = 0;//可以不用初始化11 }12 for(i ... 阅读全文
posted @ 2012-04-20 11:41 tomctx 阅读(204) 评论(0) 推荐(0) 编辑