求解五元一次方程的C#算法
在网上搜了下,说关于求解五元一次方程的C#算法很多,源代码也很多,但我却找不到。那位给个C#的源代码,在线等,谢谢。在最好是用高斯消元法。
------解决方案--------------------是方程组吧? 
 应该用矩阵来处理,大学的线性代数有讲。 
 另外大学学过《计算方法》也有解方程组的算法流程图和源码
------解决方案--------------------http://www.codeproject.com/csharp/matrix.asp
------解决方案--------------------回去翻下 <线性代数> 就知道了
------解决方案--------------------sub gaussj(a(), n, b()) 
  '高斯消元法。 
     dim ipiv(50), indxr(50), indxc(50) 
     for j = 1 to n 
         ipiv(j) = 0 
     next  
     for i = 1 to n 
         big = 0 
         for j = 1 to n 
             if ipiv(j)  <>  1 then 
                 for k = 1 to n 
                 if ipiv(k) = 0 then 
                     if abs(a(j, k)) > = big then 
                         big = abs(a(j, k)) 
                         irow = j 
                         icol = k 
                     end if 
                 elseif ipiv(k) >  1 then 
                     havaResult = false 
 					exit sub 
                 end if 
                 next  
             end if 
         next  
         ipiv(icol) = ipiv(icol) + 1 
         if irow  <>  icol then 
             for l = 1 to n 
                 dum = a(irow, l) 
                 a(irow, l) = a(icol, l) 
                 a(icol, l) = dum 
             next  
             dum = b(irow) 
             b(irow) = b(icol) 
             b(icol) = dum 
         end if 
         indxr(i) = irow 
         indxc(i) = icol 
         if a(icol, icol) = 0 then  
 			 havaResult = false 
 			exit sub 
 		end if 
         pivinv = 1 / a(icol, icol) 
         a(icol, icol) = 1 
         for l = 1 to n 
             a(icol, l) = a(icol, l) * pivinv 
         next  
         b(icol) = b(icol) * pivinv 
         for ll = 1 to n 
             if ll  <>  icol then 
                 dum = a(ll, icol) 
                 a(ll, icol) = 0 
                 for l = 1 to n 
                     a(ll, l) = a(ll, l) - a(icol, l) * dum 
                 next  
                 b(ll) = b(ll) - b(icol) * dum 
             end if 
         next  
     next  
     for l = n to 1 step -1 
         if indxr(l)  <>  indxc(l) then 
             for k = 1 to n 
                 dum = a(k, indxr(l)) 
                 a(k, indxr(l)) = a(k, indxc(l)) 
                 a(k, indxc(l)) = dum 
             next  
         end if 
     next  
 end sub
------解决方案--------------------#include  <stdio.h>  
 #include  <conio.h>  
 #include  <stdlib.h>  
 #include  <math.h>      
 float *GauseSeidel(float *c,int n) 
 { 
 	int i,j,k,t; 
 	float *x,p; 
 	x=(float *)malloc(n*sizeof(float)); 
 	for(i=0;i <=n-2;i++) 
 	{ 
 		k=i; 
 		for(j=i+1;j <=n-1;j++) 
 			if(fabs(*(c+j*(n+1)+i))> (fabs(*(c+k*(n+1)+i))))k=j; 
 			if(k!=i) 
 				for(j=i;j <=n;j++) 
 				{ 
 					p=*(c+i*(n+1)+j); 
 					*(c+i*(n+1)+j)=*(c+k*(n+1)+j); 
 					*(c+k*(n+1)+j)=p; 
 				} 
 				for(j=i+1;j <=n-1;j++) 
 				{ 
 					p=(*(c+j*(n+1)+i))/(*(c+i*(n+1)+i)); 
 					for(t=i;t <=n;t++) 
 						*(c+j*(n+1)+t)-=p*(*(c+i*(n+1)+t)); 
 				} 
 	} 
 	for(i=n-1;i> =0;i--) 
 	{ 
 		for(j=n-1;j> =i+1;j--) 
 			(*(c+i*(n+1)+n))-=x[j]*(*(c+i*(n+1)+j)); 
 		x[i]=*(c+i*(n+1)+n)/(*(c+i*(n+1)+i));