- 博客(22)
- 资源 (3)
- 收藏
- 关注
转载 【面试题】strcmp函数实现
#include #include using namespace std;int strcmp_mf(const char *src,const char *dst){ assert(src != NULL && dst != NULL); while(*src++ == *dst++) { if(*src=='\0' && *dst=='\0') { retur
2012-04-29 10:34:18 1130
转载 回文数-使用指针
#include using namespace std;bool isPalindrome(char *input){ if(input == NULL) { return false; } // char *begin = input; char *end = begin + strlen(input)-1; while(begin < end) { if(*be
2012-04-29 10:09:53 1180
转载 回文数_但程序中使用了strcpy和strlen
#include #include #include #include using namespace std;bool isPalindrome(char *input){ assert(input != NULL); //定义缓存 char s[100]; strcpy(s,input); //计算输入字符串的长度 int length = strlen(input)
2012-04-29 09:55:31 783
转载 strcpy函数实现
#include #include using namespace std;char *strcpy_mf(char *dst,const char *src){ assert((dst != NULL)&&(src != NULL)); char *temp = dst; while(*src != '\0') { *dst++ = *src++; } *dst = '
2012-04-29 09:37:12 707
转载 atoi函数实现_buwanmei
//字符串转换成整数atoi函数的实现#include #include using namespace std;int atoi_mf(char s[]){ assert(s != NULL); int i = 0; int sum = 0; int sign; //跳过空格和制表符 while(' ' == s[i] || '\t' == s[i]) { i++;
2012-04-28 22:43:34 2071
转载 atoi实现_字符串中含有字母_处理的不好哎
#include using namespace std;int isspace(int x){ if(x==' '||x=='/t'||x=='/n'||x=='/f'||x=='/b'||x=='/r') { return 1; } else { return 0; }}int isdigit(int x){ if(x='0')
2012-04-28 22:41:43 2763
转载 itoa函数实现
//整形转成字符串函数实现//题目不难,重点考察面试者对问题考虑的全面程度#include using namespace std;void itoa_mf(int num,char str[]){ int sign = num; int i = 0; int j = 0; char temp[100]; //如果是负数就去掉符号,将-1234转成1234 if(sign <
2012-04-28 21:50:09 5295
转载 分别使用二维统计滤波对椒盐噪声和高斯噪声进行滤波
function FuShiPengZhangI=imread('C:\Users\user\Desktop\data\Gabor-1-120\2-1.jpg');J1=imnoise(I,'salt & pepper',0.004); subplot(2,3,1);imshow(I); title('原始图像'); subplot(2,3,2);imshow(J1);title('加
2012-04-25 09:43:55 2387
转载 对加入椒盐噪声的图像分别作均值、中值和维纳滤波
function FuShiPengZhang%I=imread('C:\Users\user\Desktop\data\Gabor-1-120\2-1.jpg'); %J1=imnoise(I,'gaussian',0,0.02); %J2=imnoise(I,'salt & pepper',0.02); %J3=imnoise(I,'speckle',0.02); %运行效果见图2
2012-04-25 09:30:36 7107
转载 二维自适应维纳滤波对高斯噪声的滤除效果
function FuShiPengZhangI=imread('C:\Users\user\Desktop\data\Gabor-5-80-0.5-0.5\2-5.jpg'); %读取图像 J=imnoise(I,'gaussian',0,0.005); %加入均值为0,方差为0.005的高斯噪声 K1=wiener2(J,[3 3]); %对加噪图像进行二维自适应维纳滤波 K2=wie
2012-04-25 09:18:10 8396
转载 均值滤波对高斯噪声的效果
function FuShiPengZhangI=imread('C:\Users\user\Desktop\data\Gabor-5-80-0.5-0.5\2-5.jpg');%读取图像 J=imnoise(I,'gaussian',0,0.005);%加入均值为0,方差为0.005的高斯噪声 subplot(2,3,1);imshow(I);title('原始图像');subplo
2012-04-25 09:15:18 8989
转载 输出一个整数的所有因子
//求一个整数的所有因子~~#include using namespace std;//判断一个数是不是质数int isPrime(int a){ int i; for(i=2; i<=a-1; ++i) { if(a % i == 0) { return 0; } } return 1;}//求因子void PrimeFactor(int n){
2012-04-24 22:37:43 14238
转载 Hanoi塔问题_经典
#include using namespace std;//移动盘子,从A到Bvoid Move(int n,char A,char B){ cout << "move " <<n<<" from "<<A<<" To " <<B<< endl;}//目的从A移动到B上去,过程中盘子要保持有序void Hanoi(int n,char A,char B,char C){ if
2012-04-24 21:54:14 1046
转载 字符串第一个重复出现的字符_超级牛逼的死想
//找出一个字符串中第一个重复出现的字符//超级牛逼的方法#include #include #include //memset#include #include #define N 256char Find(char str[], int n){ char temp[N] = {0}; char dst; //memset((void *)temp,0x00,N*siz
2012-04-24 21:08:53 3741
转载 冒泡排序小盖饭
//冒泡排序的小改进//设置个信号量change//当某一次没有交换时表明当前数组已有序#include #include using namespace std;void bubbleSort(int a[], int n){ bool change = true; for(int i=n-1; i>=1 && change; --i) { change = false
2012-04-24 18:48:17 529
转载 字符串查重-玩赖版
//字符串查重,利用set容器的特性#include #include #include using namespace std;void deleteSame(const char *str){ assert(str != NULL); set s; for(int i=0; str[i] != '\0'; ++i) { s.insert(str[i]); } fo
2012-04-24 18:39:26 1551
转载 n是2的几次方?
#include using namespace std;void method_bxy(int n){ int count = 0; while(1) { if(1 == n) { cout << "n为2的" << count <<"次方"<<endl; break; } if(0 == n%2) { ++count; n /= 2;
2012-04-22 09:13:31 2272 2
转载 atoi函数实现
#include #include int atoi(const char *str){ int signal=1; int result=0; assert(str != NULL); if((*str>='0'&& *str<='9') || *str=='-' || *str=='+') { if(*str=='-' || *str=='+') { if(*st
2012-04-21 14:45:06 662
转载 strstr函数实现
#include #include #include #include //在s1中查找s2,并返回s2在s1中第一次出现的位置char *strstr_bxy(const char *s1,const char *s2){ assert(s1 != NULL && s2 != NULL); if(*s2 != '\0') { while(*s1 != '\0') {
2012-04-20 21:03:23 726
转载 常见面试题_自我陶醉
#include #include #include using namespace std;//求二个集合A、B交集的补集,类似于异或操作void f(const set &A,const set &B,set &C){ C = A; //用于存放插入元素是否成功 pair::iterator,bool> ele; for(set::const_iterator iter=B
2012-04-20 20:25:07 665
原创 输入数据将重复的剔除掉,剩下的写到文件中
//测试程序,输入一些数字,插入到一个向量中,如果重复输入则丢弃,最后保证向量中的数字是不重复的#include #include #include #include using namespace std;void main(){ vector v; int x; fstream f_bxy; f_bxy.open("d:\\test.txt",ios::out); wh
2012-04-20 09:51:12 493
原创 find函数查重_自我回顾
//测试程序,输入一些数字,插入到一个向量中,如果重复输入则丢弃,最后保证向量中的数字是不重复的#include #include #include using namespace std;void main(){ vector v; int x; while(1) { cin >> x; if(x == 0) { break; } if(find(v
2012-04-20 09:13:18 1207
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人