الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف]ساعدوني في الحل

مغلق
بدأه monahe2000 في 27 مايو 2008 · 10 رد · 953 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

الموضوع هو واجب مطلوب علي وهو

برنامج يحل معادلة من الدرجة الثالثة

bX^3 + cX^2 + d = 0

هذا البرنامج لحل معادلة من الدرجة الأولي و الثانيه و الثالثة و الرابعة علي الأشكال الاتيه

aX+b=0

aX^2 + bX + c =0

aX^3 + bX^2 + cX + d = 0

aX^4 + bX^3 + cX^2 + d = 0

انا ابيه يحل بس من الدرجة الثالثة تكفون ساعدوني

#include<iostream.h>
#include<math.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<graphics.h>
#include<dos.h>

char  v;
float a,b,c,d,e,x1,x2;
float a0,a1,a2,a3,a4,f,g,A,B,C,p,q,l,k,n,X1,P,O,aa;
int i=1;
char chs;

char high[7][300]={"  --(R) = Enter new equation . --(B) = back .  --(X) = exit .",
						 "   --(1,2,3,4)no. = Solve equations . --(b) = Log off .  --(Other key) = exit .",
						 "  ##  Welcome In M. C. T. Programmes ##",
						 "  --(Other key) = Enter to program .   --(X) = exit .",
						 "  ##  Solve  ##"			  };


void draw11 (int f)
{
int maxx=getmaxx();int maxy=getmaxy();
int rect1[]={(0),(0),(maxx),(0),(maxx),(15),(0),(15),(0),(0)};
setlinestyle(0,3,3);
settextstyle(0 ,0 ,1 );
setcolor(7);
drawpoly(5,rect1);
setfillstyle(1,7);
fillpoly(5,rect1);
setcolor(1);
outtextxy(0,7,high[f]);
}

void draw12 (int f)

{
int maxx=getmaxx();int maxy=getmaxy();
int rect2[]={(0),(maxy-15),(maxx),(maxy-15),(maxx),(maxy),(0),(maxy),(0),(maxy-15)};
setlinestyle(0,3,3);
settextstyle(0 ,0 ,1 );
setcolor(7);
drawpoly(5,rect2);
setfillstyle(1,7);
fillpoly(5,rect2);
setcolor(RED);
outtextxy(0,maxy-10,high[f]);

}





/////////////////////////////  main  ///////////////////////


void  main (void)

{

void   introduction									   (void);
void   passward										   (void);

void   english_choose_equations						   (void);

void   first_degree_entering_coffecient_english		   (void);

void   second_degree_entering_coffecient_english		  (void);
void   third_degree_entering_coffecient_english		   (void);



void   print_solve_second_degree_first_condition_english  (void);
void   print_solve_second_degree_second_condition_english (void);
void   print_solve_second_degree_third_condition_english  (void);

void   print_solve_third_degree_first_condition_english  (void);
void   print_solve_third_degree_second_condition_english (void);
void   print_solve_third_degree_third_condition_english  (void);

void three (void);
void four (void);

introduction:

introduction();

if (v=='x')
goto end;
else
goto passward;


passward:

cleardevice();
passward();


english_choose_equations:
cleardevice();
a=b=c=d=e=x1=x2=p=q=f=g=0;
english_choose_equations();




if (v =='1') goto first_degree_entering_coffecient_english ;
if (v =='2') goto second_degree_entering_coffecient_english;
if (v =='3') goto three ;
if (v =='4') goto four;
if (v =='b') goto passward;
else goto end;


first_degree_entering_coffecient_english :
cleardevice();
first_degree_entering_coffecient_english ();

if(v=='r')
	goto first_degree_entering_coffecient_english;
else
	 {if(v=='b')goto english_choose_equations;
	  else		 goto end;
	 }


second_degree_entering_coffecient_english:
cleardevice();
second_degree_entering_coffecient_english();


if(d>0 ) goto print_solve_second_degree_first_condition_english ;
else
		 {
		 if(d<0 ) goto print_solve_second_degree_second_condition_english ;
		 else	  goto print_solve_second_degree_third_condition_english ;
		 }


print_solve_second_degree_first_condition_english:
cleardevice();
print_solve_second_degree_first_condition_english  ( );


if(v=='r')
	goto second_degree_entering_coffecient_english;
else
	 {if(v=='b')goto english_choose_equations;
	  else		 goto end;
	 }




print_solve_second_degree_second_condition_english:
cleardevice();
print_solve_second_degree_second_condition_english ( );


if(v=='r')
	goto second_degree_entering_coffecient_english;
else
	 {if(v=='b')goto english_choose_equations;
	  else		 goto end;
	 }


print_solve_second_degree_third_condition_english:
cleardevice();
print_solve_second_degree_third_condition_english ( );

if(v=='r')
	goto second_degree_entering_coffecient_english;
else
	 {if(v=='b')goto english_choose_equations;
	  else		 goto end;
	 }




three:
cleardevice();
three();




if(v=='r')
	goto three;
else
	 {if(v=='b')goto english_choose_equations;
	  else		 goto end;
	 }




four:
cleardevice();
four();

if(v=='r')
	goto four;
else
	 {if(v=='b')goto english_choose_equations;
	  else		 goto end;
	 }

end:
}

///////////////////////////////////  passward  ////////////////////////////////


void passward (void)

{
void rat (int,int,int,int,int,int,int);
void ratin (int,int,int,int,int,int,int);

int maxx=getmaxx();int maxy=getmaxy();
int b,t;
int i=0,m;

char n='0',s[30];

b=3;

g:
cleardevice();
setcolor(WHITE);




rat((maxx/2-100),(maxx/2+100),(maxy/2-23),(maxy/2-17),0,b,0);


rat((maxy/2-23),(maxy/2+57),(maxx/2+100),(maxx/2+105),0,b,1);


ratin ((maxx/2-100),(maxx/2+105),(maxy/2+57),(maxy/2+62),0,b,0);


ratin ((maxy/2-23),(maxy/2+62),(maxx/2-105),(maxx/2-100),0,b,1);


outtextxy(maxx/2-90,maxy/2-10,"Log in   : M.C.T");
delay(300);
outtextxy(maxx/2-90,maxy/2+15,"Passward :");



n='0';
i=0;

t=maxx/2-20;




while(n != '\r' )
{
n=s=getch();

if  ( s=='\b')  {
						  if (i>0)
							  {
							  i=i-1;
							  //t=t-10;
							  setcolor(BLACK);

							  outtextxy(t,maxy/2+15,"*");
							  t=t-10;
							  }
						  }

else
							  {
							  i=i+1;
							  if(n== '\r') break;
							  else
								  {
								  setcolor(WHITE);
								  t=t+10;
								  outtextxy(t,maxy/2+15,"*");
								  }
							  }


}
if ( (s[0]=='0'&&s[1]=='0'&&s[2]=='1'&&s[3]=='1'&&s[4]=='2'&&s[5]=='9'&&s[6]=='\r')  || (  s[0]=='h'&&s[1]=='i'&&s[2]=='g'&&s[3]=='h'&&s[4]=='s'&&s[5]=='p'&&s[6]=='e'&&s[7]=='e'&&s[8]=='d'&&s[9]=='\r' ) )
	{
	cleardevice();

	}
else
	{
	setcolor(BLACK);
	for(i=maxx/2-90;i<=maxx/2+90;i++)
		{
		for(m=maxy/2;m<=maxy/2+30;m++)
			{
			putpixel(i,m,BLACK);
			}
		 }

	setcolor(RED);
	outtextxy(maxx/2-90,maxy/2+20,"Incorrect passward .");
	outtextxy(maxx/2-90,maxy/2+35,"Any key to re tray .");

	getch();
	b=0;
	goto g;
	}



}



void  english_choose_equations   (void)

{
int maxx=getmaxx();int maxy=getmaxy();
setbkcolor(BLUE);
cout<<"\n";
cout<<"____________________________________________________________________________
__\n\n";
cout<<" -- press number -1- to solve first degree equation .";
cout<<"\n\n									[ a x + b = 0 ]  ";
cout<<"\n\n\n -- press number -2- to solve second degree equation . ";
cout<<"\n\n									[ a x^2 + b x + c = 0 ]  ";
cout<<"\n\n\n -- press number -3- to solve third degree equation . ";
cout<<"\n\n									[ a x^3 + b x^2 + c x + d = 0 ] ";
cout<<"\n\n\n -- press number -4- to solve fourst degree equation . ";
cout<<"\n\n									[ a x^4 + b x^3 + c x^2 + d x + e = 0 ]\n\n\n\n\n";

draw12(1);

v=getch();

}


void second_degree_entering_coffecient_english(void)

{
setbkcolor(BLUE);
x1=x2=a=c=b=d=e=0;
cout<<"\n";
cout<<" =============================================================================\n\n";
cout<<"   -- shape of equation [ a x^2 + b x + c = 0 ] -- \n\n";
cout<<"	  please enter the cofficient of x^2\t\ta = (";
cin>>a;
cout<<"	  please enter the cofficient of x  \t\tb = (";
cin>>b;
cout<<"	  please enter the absolute cofficient  \t\tc = (";
cin>>c;
d=(pow ((b),2) -(4*a*c));


}


void   print_solve_second_degree_first_condition_english   (void)

{


setbkcolor(BLUE);
  e=(pow ((b),2) -4*a*c);
  e=sqrt (e);
  x1=(-b+e)/(2*a);
  x2=(-b-e)/(2*a);

cout<<"\n\n\n\n\n\n\n  -- Equation is [ "<<a<<" x^2 + "<<b<<" x + " <<c<<" = 0 . ] \n\n";
cout<<" . . ( b^2 - 4ac ) = ( ("<<b<<")^2 - 4 * "<<a<<" * "<<c<<" ) = "<<d<<" > 0 \n";
cout<<"  .					 \n\n";
cout<<"	 This Equation Has Two Real Roots\n\n";
cout<<"	 X1 = ( "<<x1<<" )\n\n"<<"	 X2 = ( "<<x2<<" )\n\n\n\n";

draw11(4);
draw12(0);
v=getch();
}

void   print_solve_second_degree_second_condition_english   (void)

{

 setbkcolor(BLUE);
e=(pow ((b),2) - (4*a*c));
	 e=-1.0*e;
	 e=sqrt (e);
	 x1=((-b)/(2*a));
	 x2=(e)/(2*a);

cout<<"\n\n  -- Equation is [ "<<a<<" x^2 + "<<b<<" x + " <<c<<" = 0 . ] \n\n";
cout<<" . . ( b^2 - 4ac ) = ( ("<<b<<")^2 - 4 * "<<a<<" * "<<c<<" ) = "<<d<<" < 0 \n";
cout<<"  .	\n\n";
cout<<"	 This Equation Has Tow Complex Roots\n\n";
cout<<"	  ("<<-1.0*b<<")			   ("<<e<<") \n";
cout<<" X1 = ________	  +	___________   j\n";
cout<<"	   2 * "<<a<<"			  2 * "<<a<<"\n\n";
cout<<"	  ("<<-1.0*b<<")			   ("<<e<<") \n";
cout<<" X2 = ________	  -	___________   j\n";
cout<<"	   2 * "<<a<<"			  2 * "<<a<<"\n\n";
cout<<"	 X1 = ( "<<x1<<" ) + ( "<<x2<<" ) j \n\n";
cout<<"	 X2 = ( "<<x1<<" ) - ( "<<x2<<" ) j \n\n\n\n";

draw11(4);
draw12(0);

v=getch();

}

void   print_solve_second_degree_third_condition_english   (void)

{


 setbkcolor(BLUE);
e=(pow ((b),2) -4*a*c);
	 e=sqrt (e);
	 x1=(-b+e)/(2*a);
	 x2=(-b-e)/(2*a);

cout<<"\n\n\n  -- Equation is [ "<<a<<" x^2 + "<<b<<" x + " <<c<<" = 0 . ] \n\n";
cout<<" . . ( b^2 - 4ac ) = ( ("<<b<<")^2 - 4 * "<<a<<" * "<<c<<" ) = "<<d<<" = 0 \n";
cout<<"  .					 \n\n";
cout<<"	 This Equation Has Two Real Roots\n\n";

if (x1==x2)
{cout<<"	 X1 = X2 = ( "<<x1<<" )\n\n";}
else
{cout<<"	 X1 = ( "<<x1<<" )\n\n"<<"	 X2 = ( "<<x2<<" )\n\n\n\n";}

draw11(4);
draw12(0);
v=getch();
}

void first_degree_entering_coffecient_english (void)
{

setbkcolor(BLUE);
cout<<"\n";
cout<<" =============================================================================\n";
cout<<"   -- shape of equation [ a x + b = 0 ] -- \n\n";
cout<<"	  please enter the cofficient of x\t\ta = (";
cin>>a;
cout<<"	  please enter the free cofficient	\tb = (";
cin>>b;
cleardevice();

cout<<"\n\n\n  -- Equation is [ "<<a<<" x + "<<b<<"  = 0 . ] \n\n";
cout<<"\n\n "<<a<<" x = -b = "<<-b;
cout<<"\n\n x = -b / a = "<<-b<<"/"<<a;
cout<<"\n\n x =" <<(-b/a);
cout<<"\n\n\n\n";

draw11(4);
draw12(0);
v=getch();
}


void sign()
{
 g=22.0*g/(180*7*3);
 g=cos(g);
}
void sec()
{
if(pow(l,2)<4*k)
{
n=4*k-pow(l,2);n=sqrt(n)/2.0;l=l/2.0;
cout<<"\n\tX"<<i<<"="<<-l<<" +j"<<n;i++;cout<<"\n\tX"<<i<<"="<<-l<<"-j"<<n;i++;
}
else
{
	n=pow(l,2)-4*k;
	n=sqrt(n)/2.0; l=l/2.0;
	cout<<"\n\tX"<<i<<"="<<-l+n;i++;cout<<"\n\tX"<<i<<"="<<-l-n;i++;
}
}


//////////////////////////////  four  //////////////////////////////////////////

void four ()
{
cout<<"  --  The General shape of equation is\n\n";
cout<<"	  [ a1 X^4 + a2 X^3 + a3 X^2 + a4 X +  c = 0 ]\n\n\n";
cout <<"\n\nPlease enter the coefficient of X4 then press Enter	  a1= ";
cin >>a0;
cout <<"\n\nPlease enter the coefficient of X3 then press Enter	  a2= ";
cin >>a1;
cout <<"\n\nPlease enter the coefficient of X2 then press Enter	  a3= ";
cin >>a2;
cout <<"\n\nPlease enter the coefficient of X  then press Enter	  a4= ";
cin >>a3;
cout <<"\n\nPlease enter the absolute coefficient then press Enter   c= ";
cin >>a4;
a1=1.0*a1/a0;
a2=1.0*a2/a0;
a3=1.0*a3/a0;
a4=1.0*a4/a0;

cleardevice();

cout<<"\n\n";
cout<<"  --  The shape of equation you entered is\n\n";
cout<<"	  [ "<<a0<<" X^4 + "<<a1<<" X^3 + "<<a2<<" X^2 + "<<a3<<" X+ "<<a4<<" ]";

cout<<"\n\n\tX^4 + "<<a1<<"X^3 + "<<a2<<"X^2 + "<<a3<<"X + "<<a4<<" = 0\n\n\tX^4 + "<<a1<<"X^3  = "<<-a2<<"X^2 + "<<-a3<<"X + "<<-a4<<"\n\n\t(X^2 + "<<.5*a1<<"X + ë )^2 = ( "<<.25*pow(a1,2)-a2<<" + 2ë )X^2 + ( "<<a1<<"ë -"<<a3<<" )X + ë^2 "<<-a4<<"\n\n\t( "<<a1<<"ë "<<-a3<<" )^2 = 4 ( ë^2 "<<-a4<<" ) ( "<<.25*pow(a1,2)-a2<<" + 2ë )\n\n\t8ë^3  "<<-4*a2<<"ë^2  " <<2*a1*a3-8*a4<<"ë  "<<-pow(a3,2)-a4*pow(a1,2)+4*a4*a2;
A=-.5*a2;
B=.25*(a1*a3-4*a4);
C= -.125*(pow(a3,2)+a4*pow(a1,2)-4*a4*a2);
q=-1.0*A*(B-2*pow(A,2)/9)/3+C;
p=1.0*(B-pow(A,2)/3);
p=p/3.0;
q=q/2.0;
a=pow(q,2)+pow(p,3);
if(a>0)
		{
		a=sqrt(a);
		f=-q+a;

		if(f<0)
				{
				f=pow(f,2);
				f=pow(f,(1.0/6));
				f=-f;
				}
		else
				f=pow(f,(1.0/3));
		g=-q-a;

		if(g<0)
				{
				g=pow(g,2);
				g=pow(g,(1.0/6));
				g=-g;
				}
		else  g=pow(g,(1.0/3));

		p=f+g;
		q=f-g;
		X1=p-A/3.0;
		}
else
		{
		if(a==0)
				 {
				 if(q<0)
						 {
						 q=-q;
						 f=pow(q,(1.0/3));
						 f=-f;
						 }
				 else
						 f=pow(q,(1.0/3));
				 X1=f-A/3.0;
				 }
		else
				 {
				 if(a<0)
						 {
						 p=pow(p,6);
						 p=pow(p,(1.0/4));
						 q=-q/p;
						 p=2*pow(p,(1.0/3));
						 q=acos(q);
						 q=q*630/11;
						 g=q;
						 sign();
						 X1=g*p-A/3.0;
						 }
				 }
		}
		 P=.25*pow(a1,2)+2*X1-a2;P=pow(P,2);P=pow(P,.25);
		 O=pow(X1,2)-a4;O=pow(O,2);O=pow(O,.25);
		 if(a1*X1<a3)
		 O=-O;cout<<" = 0\n\n\t\t Solve third degree equation - Get one solution\n\të= "<<X1<<"\n\n\t(X^2 +"<<.5*a1<<"X + "<< X1<<" )^2 = +/- ( "<<P<<"X "<<O<<" )\n\n\t\t Solve two second degree equations:\n\t THE ROOTS :-\n";
		 l=.5*a1-P;k=X1-O;
		 sec();
		 l=.5*a1+P;k=X1+O;
		 sec();
		 cout<<"\n\n";
i=1;

draw11(4);
draw12(0);
v=getch();

}

//////////////////////////////////  three  //////////////////////////////

void three ()
{
cout<<"  --  The General shape of equation is\n\n";
cout<<"	  [ a1 X^3 + a2 X^2 + a3 X + c = 0 ]\n\n\n";
cout <<"Please enter the coefficient of X3 then press Enter	  a1 = ";
cin >>a0;
cout <<"\n\nPlease enter the coefficient of X2 then press Enter	  a2 = ";
cin >>aa;
cout <<"\n\nPlease enter the coefficient of X  then press Enter	  a3 = ";
cin >>b;
cout <<"\n\nPlease enter the absolute coefficient then press Enter   c  = ";
cin >>c;

cleardevice();

cout<<"\n\n\n";
cout<<"  --  The shape of equation you entered is\n\n";
cout<<"	  [ "<<a0<<" X^3 + "<<aa<<" X^2 + "<<b<<" X + "<<c<<" ]";
aa=1.0*aa/a0;
b=1.0*b/a0;
c=1.0*c/a0;
q=-1.0*aa*(b-2*pow(aa,2)/9)/3+c;
p=1.0*(b-pow(aa,2)/3);
p=p/3.0;
q=q/2.0;
a=pow(q,2)+pow(p,3);
if(a>0)
		{
		a=sqrt(a);
		f=-q+a;

		if(f<0)
				{
				f=pow(f,2);
				f=pow(f,(1.0/6));
				f=-f;
				}
		else
				f=pow(f,(1.0/3));
		g=-q-a;

		if(g<0)
				{
				g=pow(g,2);
				g=pow(g,(1.0/6));
				g=-g;
				}
		else  g=pow(g,(1.0/3));

		p=f+g;
		q=f-g;
		cout<<"\n\n\n";
		cout<<"S.S=\n\t"<<p-aa/3.0<<"\n\t"<<-1.0*p/2-aa/3.0<<"-"<<1.0*q/2<<"*( root of(3) )*j\n\t"<<-1.0*p/2-aa/3.0<<"+"<<1.0*q/2<<"*( root of(3) )*j";
		cout<<"\n\n\n";
		draw11(4);
		draw12(0);

		}
else
		{
		if(a==0)
				 {
				 if(q<0)
						 {
						 q=-q;
						 f=pow(q,(1.0/3));
						 f=-f;
						 }
				 else
						 f=pow(q,(1.0/3));
				 f=-f;
				 cout<<"\n\n\n";
				 printf("S.S={%.2f,%.2f,%.2f}",2*f-aa/3.0,-f-aa/3.0,-f-aa/3.0);
				 cout<<"\n\n\n";
				 draw11(4);
draw12(0);

				 }
		else
				 {
				 if(a<0)
						 {
						 p=pow(p,6);
						 p=pow(p,(1.0/4));
						 q=-q/p;
						 p=2*pow(p,(1.0/3));
						 q=acos(q);
						 q=q*630/11;
						 g=q;
						 sign();
						 cout<<"\n\n\n";
						 cout<<"The result:\n X1= "<<g*p-aa/3.0;
						 g=1.0*(q+360);
						 sign();
						 cout<<"\n X2= "<<g*p-aa/3.0;
						 g=1.0*(q+720);
						 sign();
						 cout<<"\n X3= "<<g*p-aa/3.0;
						 cout<<"\n\n\n";
						 draw11(4);
draw12(0);

						 }
				 }
		}

v=getch();

}

void introduction (void)


{
void add(int,int,int);
void net (int ,int  );

int driver=DETECT,mode,maxx,maxy,x,y,a,b,Z=5;

initgraph(&driver,&mode," ");

maxx=getmaxx();
maxy=getmaxy();
delay(1000);

for(x=maxx/2-250;x<=maxx/2-210;x++)
	 {
	for(y= maxy/2-100;y<=maxy/2+100;y++)
		 {
		putpixel(x,y,Z);

		}
		delay(15);

	}

for(a=maxx/2-210,b=maxy/2-100;a<=maxx/2-180;a++,b++)
	{

	add(a,b,Z);
	}

for(a=maxx/2-149,b=maxy/2-70;a<=maxx/2-119;a++,b--)
	{

	add(a,b,Z);
	}

for(x=maxx/2-88;x<=maxx/2-47;x++)
	 {
	for(y= (maxy/2)-100;y<=maxy/2+100;y++)
		 {
		putpixel(x,y,Z);

		}
		delay(15);

	}


for(x=maxx/2-7;x<=maxx/2+33;x++)
	 {
	for(y= maxy/2-99;y<=maxy/2+100;y++)
		 {
		putpixel(x,y,Z);

		}
		delay(15);

	}


for(x=maxx/2+33;x<=maxx/2+73;x++)
	 {
	for(y=(maxy/2-99);y<=(maxy/2-59);y++)
		 {
		putpixel(x,y,Z);

		 }
		delay(15);

	}

for(x=maxx/2+33;x<=maxx/2+73;x++)
	 {
	for(y=(maxy/2+60);y<=(maxy/2+100);y++)
		 {
		putpixel(x,y,Z);

		 }
		delay(15);

	}

for(x=(maxx/2+190);x<=maxx/2+230;x++)
	 {
	for(y= maxy/2-100;y<=maxy/2+100;y++)
		 {
		putpixel(x,y,Z);

		}
		delay(15);

	}


for(x=(maxx/2+120);x<=maxx/2+300;x++)
	 {
	for(y= maxy/2-100;y<=maxy/2-60;y++)
		 {
		putpixel(x,y,Z);

		}
		delay(15);

	}


for(x=0,y=0 ;  x<=maxx ;  x=x+2,y=y+2)
	{
	delay(10);
	setcolor(BLACK);
	line(x,0,x,maxy);

  }


for(x=0,y=0 ;  x<=maxx ;  x=x+2,y=y+2)
	{
	delay(10);
	setcolor(BLACK);
	line(0,y,maxx,y);
	}

int m,u,t;

delay(1000);
setlinestyle(0,3,1);

for(x=0,y=0 ;  x<=maxx ;  x++,y++)
	{
	setcolor(BLUE);
	line(x,0,x,maxy);
	line(0,y,maxx,y);
	delay(10);
	setcolor(BLACK);
	line(x,0,x,maxy);
	line(0,y,maxx,y);

	}
cleardevice();

setlinestyle(0,3,2);
rectangle(8,8,maxx-8,maxy-8);
setcolor(9);
outtextxy(10 ,maxy/2-200 ," - Helwan university . ");
outtextxy(10 ,maxy/2-170 ," - Faculity of engineering .");
outtextxy(10 ,maxy/2-140 ," - Communication department . ");
outtextxy(10 ,maxy-50 ," - Copyright M.C.T 2006 . ");
setcolor(GREEN);
settextstyle(8 ,0 ,3 );
outtextxy(50 ,200 ," -- Equationes Solver Program  --");
setcolor(RED);
settextstyle(0 ,0 ,1 );

draw11(2);
draw12(3);

v=getch();

cleardevice();


}
void add (int e,int r,int k )
{
int w,q;

for( w=e;w<=e+30;w++)
	{
	for( q=r;q<=r+30;q++)
		{
		putpixel(w,q,k);

		}
	}
}


void rat (int q,int w, int a ,int s,int k,int l,int n)
{
int i,m;
if(n==0)
{
for(i=q;i<=w;i++)
	{
	for(m=a;m<=s;m++)
		{

		putpixel(i,m,GREEN);

		delay(k);
		}
		delay(l);
	 }

}

if(n==1)
{

for(i=q;i<=w;i++)
	{
	for(m=a;m<=s;m++)
		{
		putpixel(m,i,GREEN);

		delay (k);
		}
	 delay(l);
	 }


}

}


void ratin (int q,int w, int a ,int s,int k,int l,int n)
{
int i,m;
if(n==0)
{
for(i=w;i>=q;i--)
	{
	for(m=s;m>=a;m--)
		{

		putpixel(i,m,GREEN);

		delay(k);
		}
		delay(l);
	 }

}

if(n==1)
{

for(i=w;i>=q;i--)
	{
	for(m=s;m>=a;m--)
		{
		putpixel(m,i,GREEN);

		delay (k);
		}
	 delay(l);
	 }


}

}
#2

كنت متوقع انكم بتحفرون عنده

#4

ابي برنامج يحل معادلة من الدرجة الثالثة

aX^3 + bX^2 + cX + d = 0

#5

طيب ما هو فعلا بيحل معادلة من الدرجة الثالثة! أنا شايف فيه function إسمها three() أهو.

#6

هذا الكود الخاص بالثالثة:

#include<iostream>
#include<math.h>
using namespace std;
 float a0,aa,b,c,q=0,p=0,a=0,f=0,g=0;    
void three ()
{

cout<<"  --  The General shape of equation is\n\n";
cout<<"      [ a1 X^3 + a2 X^2 + a3 X + c = 0 ]\n\n\n";
cout <<"Please enter the coefficient of X3 then press Enter      a1 = ";
cin >>a0;
cout <<"\n\nPlease enter the coefficient of X2 then press Enter      a2 = ";
cin >>aa;
cout <<"\n\nPlease enter the coefficient of X  then press Enter      a3 = ";
cin >>b;
cout <<"\n\nPlease enter the absolute coefficient then press Enter   c  = ";
cin >>c;



cout<<"\n\n\n";
cout<<"  --  The shape of equation you entered is\n\n";
cout<<"      [ "<<a0<<" X^3 + "<<aa<<" X^2 + "<<b<<" X + "<<c<<" ]";
aa=1.0*aa/a0;
b=1.0*b/a0;
c=1.0*c/a0;
q=-1.0*aa*(b-2*pow(aa,2)/9)/3+c;
p=1.0*(b-pow(aa,2)/3);
p=p/3.0;
q=q/2.0;
a=pow(q,2)+pow(p,3);
if(a>0)
        {
        a=sqrt(a);
        f=-q+a;

        if(f<0)
                {
                f=pow(f,2);
                f=pow(f,(1.0/6));
                f=-f;
                }
        else
                f=pow(f,(1.0/3));
        g=-q-a;

        if(g<0)
                {
                g=pow(g,2);
                g=pow(g,(1.0/6));
                g=-g;
                }
        else  g=pow(g,(1.0/3));

        p=f+g;
        q=f-g;
        cout<<"\n\n\n";
        cout<<"S.S=\n\t"<<p-aa/3.0<<"\n\t"<<-1.0*p/2-aa/3.0<<"-"<<1.0*q/2<<"*( root of(3) )*j\n\t"<<-1.0*p/2-aa/3.0<<"+"<<1.0*q/2<<"*( root of(3) )*j";
        cout<<"\n\n\n";



        }
else
        {
        if(a==0)
                 {
                 if(q<0)
                         {
                         q=-q;
                         f=pow(q,(1.0/3));
                         f=-f;
                         }
                 else
                         f=pow(q,(1.0/3));
                 f=-f;
                 cout<<"\n\n\n";
                 printf("S.S={%.2f,%.2f,%.2f}",2*f-aa/3.0,-f-aa/3.0,-f-aa/3.0);
                 cout<<"\n\n\n";


                 }
        else
                 {
                 if(a<0)
                         {
                         p=pow(p,6);
                         p=pow(p,(1.0/4));
                         q=-q/p;
                         p=2*pow(p,(1.0/3));
                         q=acos(q);
                         q=q*630/11;
                         g=q;

                         cout<<"\n\n\n";
                         cout<<"The result:\n X1= "<<g*p-aa/3.0;
                         g=1.0*(q+360);

                         cout<<"\n X2= "<<g*p-aa/3.0;
                         g=1.0*(q+720);

                         cout<<"\n X3= "<<g*p-aa/3.0;
                         cout<<"\n\n\n";



                         }
                 }
        }


 cin.get();
}

int main()
{

  three ();
  cin.get();  
return 0;    
}
tvquran_6.gif

#7

فيه اشياء مافهمتها ياليت احد يشرحها لي

على عجاله

aa=1.0*aa/a0;
b=1.0*b/a0;
c=1.0*c/a0;
q=-1.0*aa*(b-2*pow(aa,2)/9)/3+c;
p=1.0*(b-pow(aa,2)/3);
p=p/3.0;
q=q/2.0;
a=pow(q,2)+pow(p,3);
if(a>0)
{
a=sqrt(a);
f=-q+a;

if(f<0)
{
f=pow(f,2);
f=pow(f,(1.0/6));
f=-f;
}
else
f=pow(f,(1.0/3));
g=-q-a;

if(g<0)
{
g=pow(g,2);
g=pow(g,(1.0/6));
g=-g;
}
else g=pow(g,(1.0/3));

p=f+g;
q=f-g;
cout<<"\n\n\n";
cout<<"S.S=\n\t"<<p-aa/3.0<<"\n\t"<<-1.0*p/2-aa/3.0<<"-"<<1.0*q/2<<"*( root of(3) )*j\n\t"<<-1.0*p/2-aa/3.0<<"+"<<1.0*q/2<<"*( root of(3) )*j";
cout<<"\n\n\n";



}
else
{
if(a==0)
{
if(q<0)
{
q=-q;
f=pow(q,(1.0/3));
f=-f;
}
else
f=pow(q,(1.0/3));
f=-f;
cout<<"\n\n\n";
printf("S.S={%.2f,%.2f,%.2f}",2*f-aa/3.0,-f-aa/3.0,-f-aa/3.0);
cout<<"\n\n\n";


}
else
{
if(a<0)
{
p=pow(p,6);
p=pow(p,(1.0/4));
q=-q/p;
p=2*pow(p,(1.0/3));
q=acos(q);
q=q*630/11;
g=q;

cout<<"\n\n\n";
cout<<"The result:\n X1= "<<g*p-aa/3.0;
g=1.0*(q+360);

cout<<"\n X2= "<<g*p-aa/3.0;
g=1.0*(q+720);

cout<<"\n X3= "<<g*p-aa/3.0;
cout<<"\n\n\n";
#8

يلناس اشرحوا لي السورس هذا والله مادخل مخي

#9

ياناس ساعدوني والله مافهمت

#10

يا ناس والله تعبت ساعدوني

#11

تأسف إدارة الفريق العربي لغلق الموضوع وذلك لمخالفته قوانين المشاركات .

قواعد طرح المشاركات

/index.php?showtopic=29343

هذا الموضوع مغلق.

مواضيع مشابهة