p=(float*)a; cout<<"Enter your Nunber of Row and Colums: "; cin>>m>>n; if((m==0&&n==1)||(m==1&&n==0)) { cout<<"Note ! your matrix only 1 value,please sure you type it correct.."<<endl; //break; } else { if(m==1&&n==1) { cout<<"Note ! your matrix only have 1 value. Please sure you type it correct.."<<endl; //break; } else cout<<"Your matrix have "<<m*n<<" value."<<endl; }
p=new float(m*n);//Allocate memory for this array,if you don't allocate memory,it'll be overlow memory cout<<"\nEnter value for this matrix: ";
for(i=0;i<m*n;i++) { cout<<"a["<<i/n<<"]["<<i%n<<"]="<<endl; cin>>*(p+i); } cout<<"Your matrix is: "<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) cout<<setw(4)/*set position of column*/<<*(p+n*i+j)<<" "; cout<<endl;
}
delete p;//Delete your memory which was allocated by system getch(); }