Flame of Soul
Главная | Регистрация | Вход

Мои записи


Главная » Статьи » Алгоритмы » Численные методы

[CPP] Метод прогонки
== Magic Technologic Inc.==
Volume 0x0c, Algoritms 0x06, Phile #0x0a of 0x0f
|=-----------------------------------------------------------------=|
|=----------------------=[ Метод прогонки  ]=----------------------=|
|=-----------------------------------------------------------------=|
|=----------------=[ Copyright (c) Flame Of Soul ]=----------------=|
|=---------------=[
[E-mail]: _allbasse@yandex.ru ]=---------------=|
|=-----------------------------------------------------------------=|
#include "stdio.h"
#include "iostream.h"
bool progonka( double *aCoefficients, double *bCoefficients,
double *cCoefficients, double *dCoefficients,
int numberOfEquation, double *solution ) {
bool result;
int i, k;
double *pCoefficients, *qCoefficients;
pCoefficients = new double[numberOfEquation];
qCoefficients = new double[numberOfEquation];
if ( bCoefficients[0] == 0 ) {
return false;}
pCoefficients[0] = - cCoefficients[0] / bCoefficients[0];
qCoefficients[0] = dCoefficients[0] / bCoefficients[0];
double temp;
for ( i = 1; i < numberOfEquation - 1; i ++ ){
temp = bCoefficients[i] + aCoefficients[i]*pCoefficients[i-1];
if ( temp == 0 ) {return false;}
pCoefficients[i] = - cCoefficients[i] / temp;
qCoefficients[i] = ( dCoefficients[i] -
aCoefficients[i]*qCoefficients[i-1] ) / temp;}
temp = bCoefficients[numberOfEquation - 1] +
aCoefficients[numberOfEquation - 1]*pCoefficients[numberOfEquation - 2];
if ( temp == 0 ) {return false;}
pCoefficients[numberOfEquation - 1] = 0;
qCoefficients[numberOfEquation - 1] = ( dCoefficients[numberOfEquation - 1]
- aCoefficients[numberOfEquation - 1]*qCoefficients[numberOfEquation -
2] ) / temp;
solution[numberOfEquation - 1] = qCoefficients[numberOfEquation - 1];
for ( i = numberOfEquation - 2; i >= 0; i -- ){
solution[i] = pCoefficients[i]*solution[i+1] + qCoefficients[i];}
return result;}

void main() {
int i, j;
int size;
double *aCoefficients, *bCoefficients, *cCoefficients,
*dCoefficients, *solution;
cout << "Metod progonki.\nEnter system dimension: ";
cin >> size;
if ( size < 1 ) {
cout << "size must be >= 2.";}
else {
aCoefficients = new double[size];
bCoefficients = new double[size];
cCoefficients = new double[size];
dCoefficients = new double[size];
solution = new double[size];
aCoefficients[0] = cCoefficients[size-1] = 0;
cout << "Enter " << 1 << " row: ( 2 elements )";
cin >> bCoefficients[0];
cin >> cCoefficients[0];
for ( i = 1; i < size - 1; i ++ ){
cout << "Enter " << i + 1 << " row: ( 3 elements )";
cin >> aCoefficients[i];
cin >> bCoefficients[i];
cin >> cCoefficients[i];}
cout << "Enter " << size << " row: ( 2 elements )";
cin >> aCoefficients[size - 1];
cin >> bCoefficients[size - 1];
cout << "Enter right part: ";
for ( j = 0; j < size; j ++ ){
cin >> dCoefficients[j];}
if ( !progonka( aCoefficients, bCoefficients, cCoefficients,
dCoefficients, size, solution ) ) {
cout << "Solution for this matrix of coefficients not exist";}
else {
cout << "Solution is:\n";
for ( j = 0; j < size; j ++ ){
cout << solution[j] << "\n";}}}
cout << "\nPress \"Enter\" to continue..." << endl;
getchar();}
|=-----------------------------=[ CPP ]=---------------------------=|
|=-----------------------------------------------------------------=|
Категория: Численные методы | Добавил: flame (23.05.2009)
Просмотров: 1518 | Комментарии: 4 | Рейтинг: 0.0/0 |
Всего комментариев: 4
4  
hot milf blowjob pics
cock too big for blowjob
hot girl gives boyfriend blowjob
forced lesbian oral sex
fuck and suck movies free
giving a girl oral sex
looking for suck job
euro mature blowjob video
blowjob explosion
march 16th masturbate and blowjob

3  
ОДНОКЛАССНИКИ ЗНАКОМСТВА

2  
htttp://google.com

1  
Good morning!
Happy New Year!
Health, luck and love!

Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]

Форма входа

Поиск

Статистика


Онлайн всего: 1
Гостей: 1
Пользователей: 0