zoukankan      html  css  js  c++  java
  • 字符数组

    #include <iostream>
    using namespace std;
    
    
    int main(){
        //C++当中字符数组赋值,''单引号中不能为空 
        char talk[10]={'G','o',' ','p','a','l','y','e','r','!'};
        for(int i=0;i<10;i++){
            cout<<talk[i];
        }
        cout<<endl;
    }

    #include <iostream>
    using namespace std;
    
    
    int main(){
        //C++当中字符数组赋值,''单引号中不能为空 
        char talk[5][5]={{' ',' ','*'},
                        {' ','*',' ',' ','*'},
                        {'*',' ',' ',' ','*'},
                        {' ','*',' ','*'},
                        {' ',' ','*'}};
        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++)
                cout<<talk[i][j];
                cout<<endl;
        }
        cout<<endl;
    }

    #include <iostream>
    #include <string.h>
    using namespace std;
    
    
    int main(){
        //C++当中字符数组赋值,''单引号中不能为空 
        char str1[30]="People's Republic of ";
        char str2[]="China";
        cout<<strcat(str1,str2);
    
    }

  • 相关阅读:
    HashMap
    java反射
    arraylist和linkedlist区别
    int和Integer的区别
    java 数组排序并去重
    矩阵链乘法问题
    找零问题
    硬币收集问题
    最大借书量问题
    钢条切割问题
  • 原文地址:https://www.cnblogs.com/aipopo/p/7903437.html
Copyright © 2011-2022 走看看