欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C++利用函數(shù)動(dòng)態(tài)創(chuàng)建二維數(shù)組

 更新時(shí)間:2019年09月18日 11:20:57   作者:好想告訴你wt  
這篇文章主要為大家詳細(xì)介紹了C++利用函數(shù)動(dòng)態(tài)創(chuàng)建二維數(shù)組,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C++利用函數(shù)動(dòng)態(tài)創(chuàng)建二維數(shù)組的具體代碼,供大家參考,具體內(nèi)容如下

很簡(jiǎn)單,使用兩個(gè)new創(chuàng)建即可。

運(yùn)行截圖及代碼如下:

#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int **creat(int m,int n)
{
 int **p;
 int i,j;
 p = new int *[m];
 for(i=0;i<m;i++)
 {
 p[i]=new int[n];
 }
 for(i=0;i<m;i++)
 for(j=0;j<n;j++) cin>>p[i][j];
 return p;
}
int main()
{
 int **p;
 int m,n;
 cout<<"input row and col:";
 cin>>m>>n;
 p=creat(m,n);
 cout<<"output:"<<endl;
 for(int i=0;i<m;i++)
 {
 for(int j=0;j<n;j++)
 {
  cout<<p[i][j]<<" ";
 }
 cout<<endl;
 }
  return 0;
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論