零碎知识

字符串问题

char *str1  = "hello"
char  str2[] ="hello"
str1不等于str2
        str1是一个字符串常量不可修改
str2是一个字符串变量可修改

char *t = "hello";
char *t2 = "hello";
t1 等于 t2;

 

C语言数组初始化问题

https://www.cnblogs.com/xiaokang01/p/12380119.html

二维容器初始化问题

//
// Created by LK on 2020/3/18.
//
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void print(vector<vector<int>>obj)
{
    for(int i=0;  i< obj.size();  i++)//输出二维动态数组
    {
        for(int j=0; j<obj[i].size(); j++)
        {
            cout  <<  obj[i][j]  <<  " ";
        }
        cout  <<  "\n";
    }
}
int main()
{

    int N=5,   M=6;
    vector<vector<int> > obj1(5,   vector<int>(6));  //定义二维动态数组5行6列
    print(obj1);

    vector<vector<int> > obj2(5);  //定义二维动态数组大小5行
    for(int i =0;  i< obj2.size();  i++)//动态二维数组为5行6列,值全为0
    {
        obj2[i].resize(6);
    }

    print(obj2);

    return 0;
}

 

相关文章:

  • 2021-12-30
  • 2021-09-18
  • 2022-02-26
  • 2021-11-10
  • 2021-06-29
  • 2022-01-16
  • 2022-02-20
  • 2021-11-16
猜你喜欢
  • 2022-12-23
  • 2021-08-12
  • 2022-01-07
  • 2022-12-23
  • 2021-11-11
  • 2021-07-19
相关资源
相似解决方案