
字符串练习
a2604539133
这个作者很懒,什么都没留下…
展开
-
01_最大公约数
int getGong( int num1 , int num2 ) { int k = num1%num2 ; while( k!=num1 ) { if( k==0 ) return num2; num1 = num2 ; num2 = k ; k = num1%num2 ; }原创 2017-07-21 11:23:04 · 307 阅读 · 0 评论 -
02_数组偶数行按从大到小排列,奇数行相反
void getGong( int a[] , int len ) { int max , min ; int temp ; for( int i=0 ; i<len-1 ; i+=2 ) { max = i , min=i ; for( int j=i+1 ; j<len ; ++j ){ if( a[i]<a[j] )原创 2017-07-21 11:49:56 · 506 阅读 · 0 评论 -
03_模仿string
模仿string函数,写出构造、析构、赋值、拷贝函数 class men{ public: men( const char *str=NULL ){ if( NULL==str ) { ptr = new char[1] ; ptr[0] = '\0' ; }els转载 2017-07-21 17:18:20 · 319 阅读 · 0 评论 -
04_检查大小端
检查处理器的储存类型,是大端还是小端。小端返回1 int checkCpu() { union cpu{ int a ; char b ; }c; c.a = 1 ; return (c.b==1) ; }转载 2017-07-21 17:25:33 · 339 阅读 · 0 评论 -
05_和最大子矩阵
/*结构体Node存放每个找到的子矩阵及其和*/ typedef struct node Node ; struct node{ int i1 , i2 , j1 , j2 , sum ; Node& operator=( Node &other ){ this->sum = other.sum ; this->i1 = other.i1 ;原创 2017-09-28 14:59:36 · 439 阅读 · 0 评论 -
06_动态规划科室
/* 1、这个是动态规划科室安排的问题,以此类推其他问题; 2、Node节点保存的是想要占用科室的时间,开始-结束,即代表一个单位的用时; */ using Node = struct node; struct node{ int begin;//开始时间 int end;//结束时间 bool flag;//这个是查看是否已经安排过这个单位 }; void getTime原创 2017-10-05 18:20:56 · 495 阅读 · 1 评论 -
07_
/*从字符串中获取尽可能多的ipv4地址*/void getIP( char *ip ) { if ( (nullptr==ip)||(strlen(ip)<4)||(strlen(ip)>12) ) { return; } char *s = ip; long long sum = 0; int i = 0; char *dest =原创 2017-10-05 20:08:21 · 355 阅读 · 0 评论