Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Курсовые / Курсовые ЭТМО / 01 / kursovay
.CPP#pragma hdrstop
#include <conio.h>
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma argsused
//grafon---------------------------------------------------------------------
void main ()
{
textbackground (BLUE);
clrscr();
window (20,10,65,20);
textbackground (RED);
textcolor(11);
clrscr();
gotoxy (1,1);
printf (" Kursovoi proekt na temu:");
gotoxy (1,3);
printf (" Reshenie algebraicheskih");
gotoxy (1,5);
printf (" uravneniy s deistvitel'nimi koefficientami");
gotoxy (1,7);
printf (" koefficientami. Metodom Hichkoka !");
window (20,20,65,30);
textbackground (GREEN);
textcolor(11);
clrscr();
gotoxy (1,4);
printf (" Vipolnil:");
printf (" Gruppa:");
gotoxy (1,6);
printf (" Frolov S.S.");
printf (" ETMO-24");
getch();
textmode(2);
int i,num=1;
double massiv[10];
//ввод степени многочлена
//cout << "Vvedite stepen' mnogochlena (ne bol'she 10): ";
//cin >> num;
num=3;
//проверка степени на соответствие параметрам
if (num>10) {cout<<"Incorrect input data. Press any key";getch();}
//ввод коэфициентов многочлена
for (i=num;i>=0;i--){
cout<<"Vvedite stepen' pri x^"<<i<<": ";
cin>>massiv[i];
}
//=============================
ofstream file;
double x=0;
double k,g,l,e,m,f;
k=massiv[3]+1;
for (;;){
g=x+massiv[2];
l=g*x+massiv[1];
if (l*x+massiv[0]<0) {x=x+k;}
k=k/2;x=x-k;
if (k<=1e-10000) break;
}
e=-g/2;
m=(e*e)-l;
if (m<0){
if (e/2<1e-5) e=0;
cout<<"x1,2="<<e<<"+-j*"<<sqrt(-m)<<" x3="<<x<<endl;
file.open("result.txt");
file<<"x1,2="<<e<<"+-j*"<<sqrt(-m)<<" x3="<<x<<endl;
file.close();
}
else{
f=sqrt(m);
cout<<"x1="<<f+e<<" x2="<<e-f<<" x3="<<x<<endl;
file.open("result.txt");
file<<"x1="<<f+e<<" x2="<<e-f<<" x3="<<x<<endl;
file.close();
}
getch();
}
Соседние файлы в папке 01