zoukankan      html  css  js  c++  java
  • 【资料备份】c++声明二维变长数组,并用memset赋予0值

    示例代码
    #include "stdafx.h"

    #include 
    <iostream>
    using namespace std;
    int _tmain(int argc, _TCHAR* argv[])
    {
        
    string s1="123456";
        
    string s2="abc";

        
    int **count=new int*[s2.size()];
        
    for (int i=0;i<s2.size();i++)
        {
            count[i]
    =new int[s1.size()];
            memset(count[i],
    0,sizeof(int)*s1.size());
        }
        
        
    for (int i=0;i<s2.size();i++)
        {
            
    for (int j=0;j<s1.size();j++)
            {
                cout
    <<count[i][j]<<endl;
            }
        }
        
    for (int i=0;i<s2.size();i++)
        {
            delete[]count[i];
        }
        delete []count;
        cout
    <<"finish"<<endl;
        
    int end;
        cin
    >>end;
        
        
    }
  • 相关阅读:
    Codeforces 1105C Ayoub and Lost Array
    绍兴市acm竞赛
    CodeForces#520 div2 1062B
    CodeForces#520 div2 1062A
    1067A
    测试MathJax
    BZOJ1010 玩具装箱toy
    停止
    秽翼
    爆零
  • 原文地址:https://www.cnblogs.com/finallyliuyu/p/1970937.html
Copyright © 2011-2022 走看看