自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 Matlab替换PNG图片透明背景为白色(先删除Alpha通道)

png图片在有Alpha通道的情况下读入matlab可能整个图片都会变黑这时即使用Matlab的imwrite将其转换为jpg格式也仍会出现上图的现象,最快捷的方法是删除png图片的Alpha通道,通过pngcrush工具可以实现;另一种可行的方法是:利用图片工厂批量转换png图片为png格式,这种方法同样可以去掉透明背景,但是图片工厂的算法会将透明背景随机填充一种除图片中所含颜色外的...

2019-11-26 13:46:41 4183

原创 C++实现批量创建二级目录

在已有二级目录结构(字符串数组)的情况下批量创建二级目录#include <direct.h>#include <io.h>#include <iostream>#include <string>using namespace std;//基于DOSint CreateFolderByDos(string strName){ st...

2019-11-22 18:52:14 342

原创 C语言 随机位置读文件

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct Stu{ char name[50]; int id;}Stu;void my_fwrite(char* path){ FILE* f...

2019-11-16 16:22:03 150

原创 C语言 按格式化读写文件fprintf/fscanf

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct Stu{ char name[50]; int id;}Stu;void my_fprintf(char* path){ FILE* ...

2019-11-16 16:07:54 263

原创 C语言 按块读写文件

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct Stu{ char name[50]; int id;}Stu;void my_fwrite(char* path){ FILE* f...

2019-11-16 15:49:16 699

原创 C语言 按行读写文件

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>void my_fputs(char* path){ FILE* fp = NULL; //"w+",读写方式打开,如果文件不存在,则创建\ 如果文件存在,...

2019-11-16 15:40:09 2462

原创 C语言 按照字符读写文件

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main00(){ fputc('a', stdout);//stdout -> 屏幕,打印普通信息 printf("\n"); char ch; ch ...

2019-11-16 14:05:43 434

原创 C语言文件写入时缓冲区验证

缓冲区是标准C独有的特性文件在写入时,先保存数据到缓冲区,当使用fflush(fp)刷新缓冲区或使用fclose(fp)关闭文件时,数据才写入文件,或者在缓冲区内存满时将早先的数据写入文件,不同平台缓冲区大小有所区别。验证缓冲区#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>...

2019-11-16 11:00:25 676

原创 C语言 结构体与指针的嵌套训练——师生按名字降序排序

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct Teacher{ char* tName;//导师 char** stu;//学生 int age;}Teacher;//在create...

2019-11-15 15:02:24 342

原创 C语言将字符串数组进行排序

/*功能:1.把指针数组p1的字符串取出来,2.把二维数组buf2的字符取出来,3.上面的字符串放到p3,p3是在堆区分配的二维内存4.对p3种字符串进行排序参数:p1:len1:p1元素个数buf2:len2:buf2字符串行数p3:二级指针的地址,需要在函数内分配内存,保存p1和buf2的字符串,还需要排序len3:保存p3中的字符串个数*/#define _CRT...

2019-11-09 22:31:54 2511

原创 C语言找数组中指定字符串位置

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>#define NUM(a) (sizeof(a)/sizeof(*a))int searchKeyTable(const char* table[], const int s...

2019-11-09 19:56:58 3619

原创 C语言二维数组的使用

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main01(){ int a1[3][4] = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12} }; int a2[3...

2019-11-09 19:20:07 860

原创 C语言数组指针详解

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>//argc:传参数的个数(包括可执行程序)//argv:指针数组,指向输入的参数int main01(int argc, char* argv[]){ //数组指针,指针...

2019-11-09 17:44:14 480

原创 C语言一维数组分析总结

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ int a[] = { 1,2,3,4,5,6,7,8 }; //sizeof()测变量所占的空间(变量所对应类型的空间) //int b[]...

2019-11-09 14:55:00 773

原创 C语言用二级指针的两种内存模式分别实现字符串分离

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>/*有一个字符串("abcdef,acccd,ddddd,fffff,sdfsd,llokkl,")写两个函数(API),输出以下结果第一个API(第二种内存模型)1)以逗...

2019-11-07 19:55:30 239

原创 C语言字符串替换

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>/*有字符串有以下特征("abcd11111abcd2222abcdqqqqq"),求写一个函数,输出以下结果把字符串替换成("dcba11111dcba2222dcbaqqq...

2019-11-07 18:30:39 1655

原创 二级指针做输入:第三种内存模型

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>char** getMem(int n){ char** buf = (char**)malloc(n * sizeof(char*)); if (buf == NULL...

2019-11-06 22:14:03 90

原创 C语言二级指针做输入:第二种内存模型

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main01(){ char a0[30] = "22222222"; char a1[30] = "11111111"; char a2[30] = "bbb...

2019-11-06 21:20:36 160

原创 C语言二级指针做输入:第一种内存模型

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>//void printArray(char* p[], int n)//等价void printArray(char** p, int n){ for (int i = 0...

2019-11-06 20:18:05 101

原创 C语言const的使用

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct MyStruct{ int a; int b;}MyStruct;void fun(MyStruct* p){ //指针能变 p=N...

2019-11-06 19:17:20 109

原创 C语言键值对查找匹配

问题描述键值对("key = value")字符串,在开发中经常使用要求1:请自定义一个接口,实现根据key获取要求2:编写测试用例要求3:键值对中间可能有n多空格,请去除空格int getKeyByValue(char* keyvaluebuf, char* key, char* value, char* valueBufLen)/*键值对("key = value")字符串,在开...

2019-11-06 18:44:28 1657

原创 C语言分离字符串的奇数位和偶数位

问题描述有一个字符串"1a2b3d4z"要求写一个函数实现如下功能:功能1:把偶数位字符挑选出来,组成一个字符串1;功能2:把奇数位字符挑选出来,组成一个字符串2;功能3:把字符串1和字符串2,通过函数参数,传给main,并打印功能4:主函数能测试通过int getStr1Str2(char* source, char* buf1, char* buf2);/*有一个字符串"1a...

2019-11-06 16:31:13 3305

原创 两头堵模型

求非空字符串的长度并输出字符串#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>int fun(char* p, int* n){ if (p == NULL || n ==...

2019-11-05 21:45:20 244 1

原创 strstr中的while和do-while模型

求字串'abcd'个数//匹配字串'abcd'#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int my_strstr(char* p, int* n){ if (p == NULL || n == NULL) {...

2019-11-05 21:08:26 85

原创 字符串拷贝函数的实现

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>void my_strcpy(char* dst, char* src){ int i; for (i = 0; *(src + i) != '\0'; i++) {...

2019-11-05 20:39:47 713

原创 字符串的初始化问题

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>/*C语言没有字符串类型,通过字符数据模拟C语言字符串,以字符‘\0’结尾,数字0*/int main01(){ //不指定长度,没有0结束符,有多少个元素就有多长...

2019-11-05 19:44:31 521

原创 指针做参数输入输出特性

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>void fun(char* p/* in */){ //给p指向的内存空间拷贝 strcpy(p, "abcdef");}void fun2(char* p){ ...

2019-11-05 18:58:02 301

原创 C通过指针间接赋值

间接赋值时指针存在的最大意义#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int getA(){ int a = 10; return a;}void getA2(int b){ b = 33;}vo...

2019-11-05 18:57:11 361

原创 不断改变指针指向

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char* p = NULL; char* q = NULL; char buf[] = "asdjkhfjk"; p = &bu...

2019-11-04 20:18:53 149

原创 指针变量和它指向的内存是两个不同概念

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>int main() { char* p = NULL; char buf[] = "abcdef"; printf("p1 = %d\n", p); //改变指针...

2019-11-04 20:01:16 333

原创 C指针也是一种数据类型

#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ int* p = NULL; char********* q = NULL; printf("sizeof(p) = %d, sizeof(q) = %d", sizeof(p), sizeof(q))...

2019-11-04 04:14:05 249

原创 C语言内存五区的使用

内存五区堆区(heap)malloc,new,free,delete,需要手动释放内存一般由程序员分配释放,若不手动释放,程序结束时可能由操作系统回收。栈区(stack)程序局部变量由编译器自动分配释放,存放函数的参数值,局部变量的值等。全局区(static)常量和全局变量全局变量和静态变量的存储是放在一起的,初始化的全局变量和静态变量在一块区域,未初始化的在相...

2019-11-04 04:09:00 316

转载 C语言main函数参数、返回值

C语言main函数返回值: main函数的返回值,用于说明程序的退出状态。如果返回0,则代表程序正常退出;返回其他数字的含义则由系统决定,通常,返回非零代表程序异常退出,即使程序运行结果正确也仍需修复代码。C语言main函数写法 void main()是错误的,C/C++中从来没有定义过main。C++之父 Bjarne Stroustrup 在他的主页上的 FA...

2019-11-04 02:00:47 2701

原创 C语言变量的本质分析

概念变量是既能读又能写的内存对象;一旦初始化后不能修改的对象是常量。变量的本质本质:一段连续内存空间的别名。程序通过变量来申请和命名内存空间,然后我们就可以通过变量名来访问内存空间。变量相当于门牌号,内存相当于房间#include <stdio.h>#include <stdlib.h>int main() { int a, * p; //直接赋值 ...

2019-11-03 20:05:34 364

原创 C语言数据类型

数据类型本质#include <stdio.h>#include <stdlib.h>int main(void){ int a; int b[10]; /*类型的本质:固定内存块大小别名 可以通过sizeof()测试 */ printf("sizeof(a) = %d, sizeof(b) = %d\n", sizeof(a), sizeof(b)...

2019-11-03 19:30:14 110

原创 C++实现选择排序

选择排序选择排序(SelectSort)是一种简单直观的排序算法。算法原理:第一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置,然后再从剩余的未排序元素中寻找到最小(大)元素,然后放到已排序的序列的末尾。以此类推,直到全部待排序的数据元素的个数为零。选择排序是不稳定的排序方法。#include<iostream>using namespace std...

2019-11-03 18:18:08 1646 1

原创 C++ 采用顺序栈的回文判断

采用顺序栈的回文判断栈是一种后进先出(LIFO)的线性表,限定仅在表尾进行插入和删除操作的线性表。这一端被称为栈顶,相对地,把另一端称为栈底。向一个栈插入新元素又称作进栈、入栈或压栈,它是把新元素放到栈顶元素的上面,使之成为新的栈顶元素;从一个栈删除元素又称作出栈或退栈,它是把栈顶元素删除掉,使其相邻的元素成为新的栈顶元素。下面给出顺序栈的操作实现顺序栈//SqStack.h#pragm...

2019-11-02 16:40:06 2341

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除