#include
#include
using namespace std;
int main()
{
char tmp;
cout<<"Please input some words(The amounts less 200 is OK else will lose words):"<
ofstream fout("test.txt");
while(cin.get(tmp))
{
if(tmp=='\n')
break;
if(tmp<='z'&&tmp>='a')
tmp=tmp-32;
fout<
fout.close();
ifstream fin("test.txt");
char ch[200];
fin.getline(ch,200);
cout<
return 0;
}
干嘛非要用数组呢,c++的string字符串类型不更安全。
#include
class Arr
{
public:
Arr(){x=0;y=0;p=NULL;}
~Arr()
{
for(int i=0;i
delete[] p;
}
int getX();
int getY();
int **getP();
void inputArr(int x,int y);
private:
int x,y;
int **p;
};
void Arr::inputArr(int m,int n)
{
int i,j;
x=m;
y=n;
p=new int*[m];
for (i=0;i
for (i=0;i
for(j=0;j
}
}
int Arr::getX()
{
return x;
}
int Arr::getY()
{
return y;
}
int** Arr::getP()
{
return p;
}
int** multiArr(Arr a,Arr b)
{
int i,j,k;
int **a1,**b1,**c1;
c1=new int*[a.getX()];
for (i=0;i
a1=a.getP();
b1=b.getP();
for (i=0;i
for (j=0;j
for (k=0;k
c1[i][j]=a1[i][k]*b1[k][j];
}
}
}
return c1;
}
int main(int argc, char* argv[])
{
Arr a,b;
int **c;
int x1,y1,x2,y2,i;
cout<<"input the row and column of first array:"<
a.inputArr(x1,y1);
cout<<"input the row and column of second array:"<
b.inputArr(x2,y2);
if(a.getY()==b.getX())
{
c=new int*[a.getX()];
for (i=0;i
c=multiArr(a,b);
cout<<"the result is:"<
for(int j=0;j
}
else
cout<<"the two array don't multiplicate!"<
}
#include
class Arr
{
public:
Arr(){x=0;y=0;p=NULL;}
int getX();
int getY();
int **getP();
void inputArr(int x,int y);
private:
int x,y;
int **p;
};
void Arr::inputArr(int m,int n)
{
int i,j;
x=m;
y=n;
p=new int*[m];
for (i=0;i
for (i=0;i
for(j=0;j
}
}
int Arr::getX()
{
return x;
}
int Arr::getY()
{
return y;
}
int** Arr::getP()
{
return p;
}
int** multiArr(Arr a,Arr b)
{
int i,j,k;
int **a1,**b1,**c1;
c1=new int*[a.getX()];
for (i=0;i
a1=a.getP();
b1=b.getP();
for (i=0;i
for (j=0;j
for (k=0;k
c1[i][j]=a1[i][k]*b1[k][j];
}
}
}
return c1;
}
int main(int argc, char* argv[])
{
Arr a,b;
int **c;
int x1,y1,x2,y2,i;
cout<<"input the row and column of first array:"<
a.inputArr(x1,y1);
cout<<"input the row and column of second array:"<
b.inputArr(x2,y2);
if(a.getY()==b.getX())
{
c=new int*[a.getX()];
for (i=0;i
c=multiArr(a,b);
cout<<"the result is:"<
for(int j=0;j
}
else
cout<<"the two array don't multiplicate!"<
}