雅克比迭代法
# include <iostream> # include "math.h" using namespace std ; //n为方程的阶数 # define n 6 //方程组的系数矩阵、常数项向量、初值向量 double a [ 6 ] [ 6 ] = { { 4 , - 1 , 0 , - 1 , 0 , 0 } , { - 1 , 4 , - 1 , 0 , - 1 , 0 } , { 0 , - 1 , 4 , - 1 , 0 , - 1 } , { - 1 , 0 , - 1 , 4 , - 1 , 0 } , { 0 , - 1 , 0 , - 1 , 4 , - 1 } , { 0 , 0 , - 1 , 0 , - 1 , 4 } } , b [ n ] = { 0 , 5 , - 2 , 5 , - 2 , 6 } , x [ n ] = { 0 , 5 , - 2 , 5 , - 2 , 6 } , c [ n ] ; //counter为最大迭代次数 int i = 0 , j , k = 0 , counter = 100 ; int main ( ) { int k = 0 , i = 0 ; double num1 , E ; float y [ n ] ; do { E = 0 ; for ( j = 0 ; j < n ; j ++ ) c [