VB.NET中的克莱默规则的代码? [英] code for cramer's rule in VB.NET?

查看:64
本文介绍了VB.NET中的克莱默规则的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我在VB.NET中编写克莱默数学规则的代码吗?
请任何人知道,然后向我提供该程序的代码.
我知道用C语言编写的代码,但在VB.NET/C#.NET中进行转换存在一些问题.
代码是.


克拉默规则......... :)

can anyone help me in writing a code for cramer''s rule of mathematics in VB.NET?
please anyone knows then provide me the code of this program.
i know the code in c language but there is some problem in converting it in VB.NET/C#.NET

the code is.


CRAMER’S rule................:)

#include <stdio.h>

int det3(int a[3][3]);

int main(void)
{
	int A[3][3];
	int B[3];

	printf("This program uses Cramer's Rule to solve a linear system.\
			Enter each of 3 linear equations as four integers separated by space.\
			  For example, x - 2y + 3z = 4 should be entered as 1 -2 3 4");
	printf("\n\nEnter equation 1: ");
	scanf("%i %i %i %i", &A[0][0], &A[0][1], &A[0][2], &B[0]);
	printf("Enter equation 2: ");
	scanf("%i %i %i %i", &A[1][0], &A[1][1], &A[1][2], &B[1]);
	printf("Enter equation 3: ");
	scanf("%i %i %i %i", &A[2][0], &A[2][1], &A[2][2], &B[2]);

	/*Finding determinants*/

	int detx[3][3] = {{B[0],A[0][1],A[0][2]},{B[1],A[1][1],A[1][2]},
						  {B[2],A[2][1],A[2][2]}};
	int dety[3][3] = {{A[0][0],B[0],A[0][2]},{A[1][0],B[1],A[1][2]},
						  {A[2][0],B[2],A[2][2]}};
	int detz[3][3] = {{A[0][0],A[0][1],B[0]},{A[1][0],A[1][1],B[1]},
						  {A[2][0],A[2][1],B[2]}};

	/* Code that determines if the system has a unique solution */

	  if(det3(A)!=0)
			 printf("\nSystem has a unique solution ( %d, %d, %d)",
			 det3(detx)/det3(A), det3(dety)/det3(A), det3(detz)/det3(A));
	  else
			 printf("\nSystem does not have a unique solution because determinant is 0");

	return 0;
}
int det3(int a[3][3])
{
	return (a[0][0]*a[1][1]*a[2][2])-(a[0][0]*a[1][2]*a[2][1]),
				+(a[0][1]*a[1][2]*a[2][0])-(a[0][1]*a[1][0]*a[2][2]),
				+(a[0][2]*a[1][0]*a[2][1])-(a[0][2]*a[1][1]*a[2][0]);
}

推荐答案

检查以下链接:

https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId = 7066& lngWId = 10 [
Check the following link :

https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7066&lngWId=10[^]


这篇关于VB.NET中的克莱默规则的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆