?? approach.cpp
字號:
// Approach.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <math.h>
#include <iostream.h>
#define n 3
void Gauss(double a[n][n],double b[n]);
int main(int argc, char* argv[])
{
double a[3][3]={{2,6,-4},{1,4,-5},{6,-1,18}};
double b[3]={4,3,2};
Gauss(a,b);
for (int i=0;i<n;i++)
{
cout<<b[i]<<endl;
}
return 0;
}
void Gauss(double a[n][n],double b[n])
{
double temp;
for (int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
temp=a[j][i];
for (int k=i;k<n;k++)
{
a[j][k]-=((a[i][k])*(temp/a[i][i]));
}
b[j]-=b[i]*(temp/a[i][i]);
}
}
for(i=n-1;i>=0;i--)
{
temp=0;
for(int j=i+1;j<=n-1;j++)
temp+=a[i][j]*b[j];
b[i]=(b[i]-temp)/a[i][i];
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -