随笔分类 - 算法之路
主要记录研究算法的历程及心得体会
摘要:插入排序:Insert_Sort(int arr[],int length){ int key = 0; int j = 0; for (int index = 1; index < length; index++) { key = arr[index]; j = index - 1; //如果将While条件写为:arr[j] > key && j > 0,可能会出现越界异常 while(j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]...
阅读全文
摘要:该代码是读大学期间写的,今天整理电脑就将原来写的代码贴出来。#include "iostream"using namespace std;int const null=0;//下面所有的如果超出链表的长度范围,就返回0struct listNode{ int data; listNode *next;};//创建链表listNode* InitList(){ listNode *headNode = new listNode; headNode->next = null; headNode->data = null; listNode *currentN...
阅读全文
摘要:最近找工作,参加过一些公司的笔试,面试。下面把笔试过的一些算法题用代码写出来,和大家分享讨论下。一 .实现字符串的拷贝功能。char* strcpy(char* dst, char* src)//把src内存位置的字符串拷贝到dst内存位置char* strcpy(char *dst, char *src){ char *tempDst = dst; //测试字符串的长度,如果目标字符串长度大于源字符串,返回目标指针dst,否则,返回NULL if(strlen(dst) > strlen(src)) { while(*src != '\0') ...
阅读全文

浙公网安备 33010602011771号