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