摘要:
题目:在一个int数组里查找这样的数,它大于等于左侧所有数,小于等于右侧所有数。答:#include "stdafx.h"#include <iostream>using namespace std;//数组中大于等于左侧所有数,小于等于右侧所有数的数void FindSpecialNumber(int *arr, int length){ if (NULL == arr || length <= 0) { return; } int *rightMin = new int[length]; rightMin[length - 1] = arr[le... 阅读全文
摘要:
题目:求最大连续递增数字串(如“ads3sl456789DF3456ld345AA”中的“456789”。答:#include "stdafx.h"#include <iostream>#include <string>using namespace std;//求最大连续递增数字串string FindMaxIncreNumberSeq(string str){ if ("" == str || str.length() <= 0) { return NULL; } int maxlength = 0; int start 阅读全文
摘要:
题目:一个长度为n的数组a[0],a[1],...,a[n-1]。现在更新数组的各个元素,即a[0]变为a[1]到a[n-1]的积,a[1]变为a[0]和a[2]到a[n-1]的积,...,a[n-1]为a[0]到a[n-2]的积(就是除掉当前元素,其他所有元素的积)。要求:具有线性复杂度,且不能使用除法运算符。答:#include "stdafx.h"#include <iostream>using namespace std;void PrintArray(int *a, int length){ for (int i = 0; i < length; 阅读全文
摘要:
题目:求两个串中的第一个最长子串(神州数码以前试题)。如"abractyeyt","dgdsaeactyey"的最大子串为"actyey"。答:#include "stdafx.h"#include <iostream>#include <string>using namespace std;//两个串中的第一个最长子串string FindLongestCommonSubString(string strOne, string strTwo){ if ("" == st 阅读全文