zoukankan      html  css  js  c++  java
  • 刷题注意细节,

    零碎知识

    字符串问题

    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  <<  "
    ";
        }
    }
    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;
    }
  • 相关阅读:
    C语言II博客作业04
    C语言II博客作业03
    C语言II博客作业01
    学期总结
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言I博客作业05
    C语言I博客作业04
    C语言I博客作业03
  • 原文地址:https://www.cnblogs.com/xiaokang01/p/12520936.html
Copyright © 2011-2022 走看看