- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <values.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <cstdlib>
#include <stdlib.h>
#include <VCL.h>
#include <iostream.h>
#include <string.h>
#include <dos.h>
FILE *f=fopen( "C:\\input.txt" , "r");
FILE *f2=fopen( "C:\\output.txt" , "w");
int main() {
void readmas(float x[10][10],char name,int n);
void readmas2(float x[10],char name,int n);
float A[10][10];
float B[10];
float x[10][100];
int i,j, ha,hb,wa,n;
float E;
int k = 1;
int m = 1;
float s;
printf("Vvedite kolichestvo uravnenij:\n");
scanf("%d",&n);
printf("\nA:\n");
readmas(A, 'A',n);
printf("\nB:\n");
readmas2(B, 'B',n);
printf("\nVvedite tochnost resheniya:\n");
scanf("%f",&E);
printf("\n");
while (m > E) {
m = 0;
for (i = 1; i <= n; i++) {
s = 0;
for (j = 1; j <= n; j++) {
if (i != j) {
s = s + A[i][j]*x[j][k];
}
}
x[i][k+1] = (B[i]-s)/A[i][i];
if (abs(x[i][k+1] - x[i][k]) > m) {
m = abs(x[i][k+1] - x[i][k]);
}
}
k = k + 1;
}
for (i = 1; i <= n; i++) {
cout<<x[i][k];
cout<<"\n";
}
getch();
return 0;
}
void readmas(float x[10][10],char name,int n)
{
int i,j;
for (i=1; i<=n;i++) {
for (j=1; j<=n; j++) {
fscanf(f, "%d", &x[i][j]);
printf("%d ", x[i][j]) ;
}
printf("\n");
}