![]() |
#2
yljyljylj2013-08-25 15:33
|

#include <iostream>
using namespace std;
void show_arr(int *, int );
int main()
{
int b[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
show_arr(&b[0][0],9);
return 0;
}
void show_arr(int *p , int size)
{
for(int i = 0; i != size; i++)
cout<<p[i]<<endl;
}
如果show_arr中的输出用 cout<<*(p+i)<<endl; 这种形式好理解,但是直接用p[i]输出是怎么做到的??using namespace std;
void show_arr(int *, int );
int main()
{
int b[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
show_arr(&b[0][0],9);
return 0;
}
void show_arr(int *p , int size)
{
for(int i = 0; i != size; i++)
cout<<p[i]<<endl;
}
[ 本帖最后由 y605302737 于 2013-8-25 15:07 编辑 ]