zoukankan      html  css  js  c++  java
  • 数组的考验

    首先当然这是一个简单的程序代码,但是其中可以让你思索到很多的知识问题,了解他的操作和实现,这可以使自己在以后的学习中更容易

    #include<iostream>
    using namespace std;
    int main()
    {
        int word[5];
        cout<<"请输入五个数:"<<endl;
        for(int j=0;j<5;++j)
        cin>>word[j];
        cout<<"计算相关数值:"<<endl;
        cout<<"sizeof(word)="<<sizeof(word)<<endl;
        cout<<"sizeof(word[0])="<<sizeof(word[0])<<endl;
        cout<<"sizeof(*word)="<<sizeof(*word)<<endl;
        cout<<"*word="<<*word<<endl;
        cout<<"++*word="<<++*word<<endl;
        cout<<"*word+2="<<*word+2<<endl;
        cout<<"输出五个数"<<endl;
        for(int i=0;i<sizeof(word)/sizeof(word[0]);++i)
            cout<<word[i]<<" ";
            cout<<"\n\";
    }
    ————————————————————————————————————

    #include<iostream>
    using namespace std;
    int array1[5]={1,2,3};
    int array2[5];
    int main()
    {
        int array3[5]={3};
        int array4[5];
        cout<<"输出这五个数组的数"<<endl<<"array1:  ";
        for(int i=0;i<5;++i)
            cout<<array1[i]<<" ";
        cout<<endl<<"array2:  ";
        for(int i=0;i<5;++i)
            cout<<array2[i]<<" ";
        cout<<endl<<"array3:  ";
        for(int i=0;i<5;++i)
            cout<<array3[i]<<" ";
        cout<<endl<<"array4:  ";
        for(int i=0;i<5;++i)
            cout<<array4[i]<<" ";
        cout<<endl;

    }


    ——————————————————————————————————————

  • 相关阅读:
    CodeCraft-19 and Codeforces Round #537 (Div. 2) C. Creative Snap
    51nod 1007正整数分组(01背包变形)
    51nod 1007正整数分组(01背包变形)
    Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array
    Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array
    小a与星际探索
    小a与星际探索
    poj3764
    心理博弈
    4级
  • 原文地址:https://www.cnblogs.com/ywj2013/p/3138516.html
Copyright © 2011-2022 走看看