c 数组指针与指针数组实例比较

xiaoxiao2022-09-22  36

#include<iostream> using namespace std; int main() { double A[3][3]={{1,2,300},{4,500,6},{700,8,9}}; double (*p)[3]; p = A; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { printf("%3.0f ",*(*(p+i)+j));; } printf("\n"); } double *q[3]={A[0],A[1],A[2]}; cout<<q[0]<<endl; cout<<A[0]<<endl; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { cout<<*(*(q+i)+j)<<" "; // cout<<q[i][j]<<" "; } cout<<endl; } return 0; }
转载请注明原文地址: https://www.6miu.com/read-4977768.html

最新回复(0)