Home > Back-end >  Beg god to see where is wrong, already have a day
Beg god to see where is wrong, already have a day

Time:09-16

判断是否为回文字符串的

CodePudding user response:

S1, s2 is different character array, their value is the address of the first string, so never equal
Should use STRCMP for string comparison
Or use of the c + + standard library STD: : string string instead of c style

CodePudding user response:

S1, s2 to allocate enough space in advance, char [] s1="" this not line, into a char s1 [256]; Such as



CodePudding user response:

/*
Implement the product of two dynamic matrix algorithm (linear algebra)
*/
/*
Errors may be in 55 to 70 rows, you can try running ~
*/


#include
using namespace std;
Int main ()
{
Int m1, n1, m2, n2;
Dm2 dm1 int * *, * * and * * dm3.
Cout & lt; <"Both Please input the first matrix size m1, n1:";
Cin & gt;> M1 & gt;> N1.

Dm1=new int * (m1);//matrix dm1, establishes the m1 line
for (int i=0; i If ((dm1 [I]=new int (n1))==NULL)
exit(0);
}
Cout & lt; <"Please input matrix dm1:";
for (int i=0; i For (int j=0; J & lt; N1. J++)
Cin & gt;> Dm1 [I] [j];
}


Cout & lt; <"Both Please input the first matrix size m2, n2:";
Cin & gt;> M2 & gt;> N2.
Dm2=new int * (m2), Line/dm2/matrix, the establishment of the m2
for (int i=0; i If ((dm2 [I]=new int [n2])==NULL)
exit(0);
}

Cout & lt; <"Please input matrix dm2:";
for (int i=0; i For (int j=0; J & lt; N2. J++)
Cin & gt;> Dm2 [I] [j];
}

If (n1! M2)={
Cout & lt; <"Input error matrix, please input again!!!!!! ";
}
The else {
//the new matrix ranks as m1, n2
Dm3=new int * (m1);//dm3 matrix, the establishment of the m1 line
for (int i=0; i If ((dm3 [I]=new int [n2])==NULL)
exit(0);
}
//input dm3
for (int i=0; i For (int j=0; J & lt; N2. J++) {
For (int x=0; X & lt; M2; X++) {
Dm3 [I] [j] +=dm1 dm2 [I] [x] * [x] [j];
}
}
}

for (int i=0; i {
For (int j=0; J & lt; N2. J++)
{
Cout & lt; }
Cout & lt; <"\ n";
}

}

//release space
for (int i=0; i The delete [] dm1 [I];
}
The delete [] dm1;


for (int i=0; i The delete [] dm2 [I];
}
The delete [] dm2;

system("pause");
return 0;





}

CodePudding user response:

The
reference 3 floor weixin_43729886 response:
/*
Implement the product of two dynamic matrix algorithm (linear algebra)
*/
/*
Errors may be in 55 to 70 rows, you can try running ~
*/


#include
using namespace std;
Int main ()
{
Int m1, n1, m2, n2;
Dm2 dm1 int * *, * * and * * dm3.
Cout & lt; <"Both Please input the first matrix size m1, n1:";
Cin & gt;> M1 & gt;> N1.

Dm1=new int * (m1);//matrix dm1, establishes the m1 line
for (int i=0; i If ((dm1 [I]=new int (n1))==NULL)
exit(0);
}
Cout & lt; <"Please input matrix dm1:";
for (int i=0; i For (int j=0; J & lt; N1. J++)
Cin & gt;> Dm1 [I] [j];
}


Cout & lt; <"Both Please input the first matrix size m2, n2:";
Cin & gt;> M2 & gt;> N2.
Dm2=new int * (m2), Line/dm2/matrix, the establishment of the m2
for (int i=0; i If ((dm2 [I]=new int [n2])==NULL)
exit(0);
}

Cout & lt; <"Please input matrix dm2:";
for (int i=0; i For (int j=0; J & lt; N2. J++)
Cin & gt;> Dm2 [I] [j];
}

If (n1! M2)={
Cout & lt; <"Input error matrix, please input again!!!!!! ";
}
The else {
//the new matrix ranks as m1, n2
Dm3=new int * (m1);//dm3 matrix, the establishment of the m1 line
for (int i=0; i If ((dm3 [I]=new int [n2])==NULL)
exit(0);
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related