C/C++
姜维字伯约
这个作者很懒,什么都没留下…
展开
-
自己实现strcpy
#include char *mystrcpy(char *dest,const char *src){ if(dest==NULL&&src==NULL){ return; }char *p=dest;while(*src!='\0'){ *dest++=*src++;}return p;}void main(){ cha原创 2017-05-15 15:31:20 · 497 阅读 · 0 评论 -
递归实现最大公约数最小公倍数
#define _CRT_SECURE_NO_WARNINGS#include int fun(int m, int n){if (m%n == 0){return n; }else{return fun(n, m%n); }}void main(){int a, b原创 2017-05-15 15:15:52 · 631 阅读 · 0 评论 -
快速排序
#include #include void show(int *p, int length){for (int i = 0; i {printf("%4d", *(p + i));}}quick_sort(int *p, int start, int end){if (start{int i = start;for (int j = i +原创 2016-11-23 19:38:49 · 443 阅读 · 0 评论 -
删除一个字符串的一部分_02
//01 请编写函数。删除字符串的一部分。函数原型如下:////int del_substr(char *str, const char *substr);//函数首先判断substr是否出现在str中,如果并未出现,函数就返回0;如果出现,函数应该把str中该字符串后面的所有字符串赋值到该字符串位置,//从而删除这个字符串,然后函数返回1。如果substr多次出现在str中,函数原创 2016-11-13 17:39:13 · 1178 阅读 · 0 评论 -
C语言删除一个字符串的一部分
//01 请编写函数。删除字符串的一部分。函数原型如下:////int del_substr(char *str, const char *substr);//函数首先判断substr是否出现在str中,如果并未出现,函数就返回0;如果出现,函数应该把str中该字符串后面的所有字符串赋值到该字符串位置,//从而删除这个字符串,然后函数返回1。如果substr多次出现在str中,函数原创 2016-11-13 00:06:18 · 14699 阅读 · 0 评论 -
C语言求1-100以内的素数
#include #include void main(){for (int i = 1; i {int j = 2;for (; j{if (i%j == 0)break;}if (j>sqrt(i) && i != 1)printf("%d ", i);}system("pause");}原创 2016-11-06 21:52:16 · 25494 阅读 · 0 评论 -
封装string类
//Mystring.h#include using namespace std;class MyString{public:MyString(); //无参构造MyString(const char *p); //有参构造 C方式MyString(const MyString &obj); //有参构造C++方式~MyString(原创 2017-05-16 23:09:32 · 663 阅读 · 0 评论