资源简介
条件平差的
代码片段和文件信息
//#include
#include using namespace std;
void main()
{
int i j k n r;
std::cout << “请输入A的行数r:“ << std::endl;
std::cin >> r;
std::cout << “请输入A的列数n:“ << std::endl;
std::cin >> n;
std::cout << “请输入A:“;
int **A = new int*[r];
int **H = new int*[n];
for (i = 0; i A[i] = new int[r];
for (i = 0; i {
for (int j = 0; j < n; ++j)
std::cin >> A[i][j];
}
for (i = 0; i {
for (int j = 0; j < n; ++j)
std::cout << A[i][j] << “ “;
std::cout << std::endl;
}
std::cout << “矩阵转置后:“ << std::endl;
for (j = 0; j H[j] = new int[n];
for (j = 0; j {
for (int i = 0; i< r; i++)
{
H[j][i] = A[i][j];
std::cout << H[j][i] << “ “;
}
std::cout << std::endl;
}
float a[100][100] c[100][100] d[100][100] e[100][100] kx[100][100] Kd[100][100] v[100][100] cu[100][100];
float p[100][100];
float Q[100][100] N[100][100] w[100][10];
float t x y = 1.0 g h yu = 1.0;
int T;
T = n;
std::cout << “请输入权阵p:“ << std::endl;
for (i = 0; i {
for (j = 0; j {
std::cout << “p[“ << i << “][“ << j << “]=“;
std::cin >> p[i][j];
}
}
std::cout << “原权阵为:“ << std::endl;
for (i = 0; i {
for (j = 0; j std::cout << p[i][j] << “ “;
std::cout << std::endl;
}
for (i = 0; i {
for (j = 0; j<(2 * T); j++)
{
if (j a[i][j] = p[i][j];
else if (j == T + i)
a[i][j] = 1.0;
else
a[i][j] = 0.0;
}
}
for (i = 0; i {
for (k = 0; k {
if (k != i)
{
t = a[k][i] / a[i][i];
for (j = 0; j<(2 * T); j++)
{
x = a[i][j] * t;
a[k][j] = a[k][j] - x;
}
}
}
}
for (i = 0; i {
t = a[i][i];
for (j = 0; j<(2 * T); j++)
a[i][j] = a[i][j] / t;
}
for (i = 0; i y = y*a[i][i];
if (y == 0)
std::cout << “对不起,您输入的矩阵没有逆矩阵,请重新输入。“ << std::endl;
else
{
for (i = 0; i {
for (j = 0; j Q[i][j] = a[i][j + T];
}
std::cout << “协因数矩阵为Q:“ << std::endl;
for (i = 0; i {
for (j = 0; j std::cout << Q[i][j] << “ “;
std::cout << std::endl;
}
};
std::cout << “求N:“ << std::endl;
for (i = 0; i
- 上一篇:MFC 鼠标实时画线
- 下一篇:房屋销售管理系统C++
评论
共有 条评论