编程tricks集锦(持续更新)-菜鸡专栏

版权声明:原创不易,且看且珍惜 https://blog.csdn.net/z13653662052/article/details/85080788

Matlab:

1、判断某字符串中是否含另一个字符串或字符-strfind

2、cell元素查找:

[x y] =ind2sub(size(cellArray),find(cellfun(@(x)strcmp(x,var),cellArray)));

C++:

1、二维数组动态分配内存和释放

template <class T>
void make2dArray(T**&x, int numberOfRows, int numberOfColumns){
    x = new T*[numberOfRows];
    for(int i=0;i<numberOfRows;i++)
        x[i] = new T[numberOfColumns];
}
template <class T>
void delete2dArray(T**&x, int numberOfRows){
    for(int i=0;i<numberOfRows;i++)
        delete []x[i];
    delete []x;
    x=NULL;
}

猜你喜欢

转载自blog.csdn.net/z13653662052/article/details/85080788