Kashub's Code Barn - "aa"

podświetlone jako c (dodał(a) aa @ 2020-11-29 09:47:02)

Twoja wyszukiwarka
Podświetl ten kod w:
Ostatnio dodane:
Losowe wpisy:
#include<stdio.h>
#include <math.h>
 
#define n 4
 
int main()
{
	float R1[n][n+1] = { 
			{2, 5, 4, 5, 37},
			{3, 6, -3, 2, 26},
			{4, -8, 4, 6, 12},
			{6, 2, 7, -2, 86}
		};
	float R2[n][n+1] = {	
			{pow(10, -5), 5, 4, 5, 21.00008},
			{3, 6, -3, 2, 26},
			{4, -8, 4, 6, 12},
			{6, 2, 7, -2, 86}
		};
	float x1[n] = {}, x2[n] = {}, c1=0, c2=0, d1=0, d2=0;
	int i, j, k;
 
 
	for(i = 0; i < n; i++) 
	{
		c1 = R1[i][i];
		c2 = R2[i][i];
		for(j = i+1; j < n; j++)
		{
			d1 = R1[j][i] / c1; 
			d2 = R2[j][i] / c2;
			for(k = i; k <= n; k++) 
			{
				R1[j][k] -= R1[i][k] * d1;
				R2[j][k] -= R2[i][k] * d2;
 
			}
		}
	}
 
 
	for(i = n-1; i >= 0; i--)
	{
		c1 = R1[i][n];
		c2 = R2[i][n];
		for(k = i+1; k < n; k++)
		{
			c1 -= R1[i][k] * x1[k];
			c2 -= R2[i][k] * x2[k];	
		}
		x1[i] = c1 / R1[i][i]; 
		x2[i] = c2 / R2[i][i]; 
	}						
 
 
	printf("Dane testowe 1:\n");
	for(i = 0; i < n; i++)
	{
		printf("%f", x1[i]);
		printf("\n");
 
	}
	printf("Dane testowe 2:\n");
	for(i = 0; i < n; i++)
	{
		printf("%f", x2[i]);
		printf("\n");
 
	}
 
 
 
	return 0;
}
 
| Foteliki samochodowe | | Sklep z oponami | | Opony całoroczne | | Opony zimowe | | Opony specjalne | | Dyskretny sexshop internetowy | | Kody programów | | Skracacz adresów | | Opisy GG |