?? io_matrix.h
字號:
matrix inputmatrix(int m,int n)
{
matrix a(m,n);
double *zh,value=0.0;
zh=new double[M];
int i=0;
int static j=0;
/* Note: The number of "zh" must be equal to
the size of the matrix(columns*rows) */
char sh[20];
cout<<" \nplease input the dir of your matrix "<<(++j)<<" ( matrix.txt )" <<endl;
cin>>sh;
ifstream inClientFile(sh,ios::in);
if(!inClientFile){
cerr<<"File could not be opened!"<<endl;
exit(1);
}
while(inClientFile>>value)
{
zh[i]=value;
i++;
}
a.setdata(zh);
return a;
delete zh;
}
matrix inputmatrix(int m,int n,char sh[])
{
matrix a(m,n);
double *zh,value=0.0;
zh= new double[M];
int i=0;
ifstream inClientFile(sh,ios::in);
if(!inClientFile){
cerr<<"File could not be opened!"<<endl;
exit(1);
}
while(inClientFile>>value)
{
zh[i]=value;
i++;
}
a.setdata(zh);
return a;
delete zh;
}
matrix inputmatrix(int n,char sh[])
{
matrix a(n);
double *zh,value=0.0;
zh=new double[M];
int i=0;
ifstream inClientFile(sh,ios::in);
if(!inClientFile){
cerr<<"File could not be opened!"<<endl;
exit(1);
}
while(inClientFile>>value)
{
zh[i]=value;
i++;
}
a.setdata(zh);
return a;
delete zh;
}
int outputmatrix(matrix a)
{
int i=0,j=0,m=a.getrows(),n=a.getcols();
ofstream outClientFile("output.txt",ios::out);
if(!outClientFile)
{// overloaded ! operator
cerr<<"File could not be opened!"<<endl;
exit(1); //prototype in stdlib.h
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
outClientFile<<' '<<a.getele(i,j);
outClientFile<<'\n';
}
return 0;//ofstream destructor closes file
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -