⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringtest.cpp

📁 整数快速排序算法的简单实现。 自己在主函数中设定数组。
💻 CPP
字号:
/*
#include "afx.h"
typedef unsigned char byte;

// void SuperCString::Split(CString rawString,char sp,CString* sp_arr[],int* length)
void Split(CString rawString,CString sp,CString* sp_arr[],int* length)
{
    
    CString* arr = new CString[*length];
    int pos = 1;
    int repeatcount = 0;
    while(pos > 0){
        if(repeatcount >= *length)
		{
            break;
        }
        pos = rawString.Find(sp,0);
        if(pos > -1)
		{
            arr[repeatcount] = rawString.Mid(0,pos);
			arr[repeatcount].TrimRight();
			arr[repeatcount].TrimLeft();
		}
        else
		{
            arr[repeatcount] = rawString;
			arr[repeatcount].TrimRight();
			arr[repeatcount].TrimLeft();
		}
        rawString = rawString.Mid(pos + 1);
        repeatcount++;
    }
    *length = repeatcount;
    *sp_arr = arr;
}

int StringCount(CString str, CString cl) 
{ 
	int nCount=0;
	CString strTemp = str;
    while(1){
		strTemp.TrimRight();
        int pos = strTemp.Find(cl);
        if(pos >=0){
            strTemp = strTemp.Mid(pos+1);
			strTemp.TrimRight();
			nCount++;
        } 
		else 
		{
            break;
        }
    }

	return nCount;
}

void main()
{
	CString str = "      aaa  &   bbb   &   ccc   &   ddd&eee        ";
	CString cl = "&";
	CString* arr = NULL;
	int len = 0;
	int nCount = StringCount(str, cl);
	arr = new CString[nCount +1];
	len = nCount + 1;
	Split(str,cl,&arr,&len);
	cout << "string: " << str << "\n";
	cout << "there are " << nCount << " " << cl << " in the string.\n";
	cout << "Spliting the string to string array by &. \n";
	for(int i = 0;i<len;i++)
	{
		cout << i << ": " << arr[i] << "\n"; 
	}
	delete[] arr;
    return;
}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -