What is the difference between the two wording when the two-dimensional array is a function parameter?
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
void dfs(int (*a)[10]){
for(int i=0;i<5;i++){
for(int j=0;j<10;j++){
cout<<a[i][j]<<" ";
}
}
}
void dfs2(int a[][10]){
for(int i=0;i<5;i++){
for(int j=0;j<10;j++){
cout<<a[i][j]<<" ";
}
}
}
int main(){
int (*a)[10]=new int[5][10];
for(int i=0;i<5;i++){
for(int j=0;j<10;j++){
a[i][j]=i*j;
}
}
dfs(a);
dfs2(a);
delete []a;
return 0;
}
dfs(int (*a)[10]) and dfs2(int a[][10]) all can work,I want to know when the array very large,Will that be efficient?
Aucun commentaire:
Enregistrer un commentaire