Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
2.0 kB
1
Indexable
Never
#include<stdio.h>
#include<math.h>
void impresionecuacion(int a,int b,int c);
void formulacuadrarica(int a,int b,int c);
int main(){
	int a,b,c;
	printf("ingrese los coifiente del polinomio ax%c+bx+c=0\n",253);
	printf("\ta=");
	scanf("%d",&a);
	printf("\tb=");
	scanf("%d",&b);
	printf("\tc=");
	scanf("%d",&c);
	printf("\n");
	impresioecuacion(a,b,c);
	formulacuadrarica(a,b,c);
	return 0;
}
voidimpresioecuacion(int a,int b, int c){
	if(b<0 && c>=0){
	if(a==1){
		printf("las raices de x%c%d=0 son:\n\n",253,b,c);}
		else if(a==-1){
		printf("las raices de x%c%d=0 son:\n\n",253,b,c);}
		else{
		printf("las raices de %dx%c%dx+%d=0 son:\n\n",a,253,b,c);}}
		else if(b>=0 && c<0){
			if(a==1){
		printf("las raices de x%c+%dx%d=0 son:\n\n",253,b,c);}
		else if(a==-1){
		printf("las raices de -x%c+%dx%d=0 son:\n\n",253,b,c);}
		else{
		printf("las raices de %dx%c+%dx%d=0 son:\n\n",a,253,b,c);}}
		
		else if(b<0 && c<0){
			if(a==1){
		printf("las raices de x%c%dx%d=0 son:\n\n",253,b,c);}
		else if(a==-1){
		printf("las raices de -x%c%dx%d=0 son:\n\n",253,b,c);}
		else{
		printf("las raices de %dx%c%dx+%d=0 son:\n\n",a,253,b,c);}}
		
		else{
		if(a==1){
		printf("las raices de x%c+%dx+%d=0 son;\n\n",253,b,c);}	
		else if(a==-1){
		printf("las raices de -x%c+%dx+%d=0 son:\n\n",253,b,c);}
		else{
		printf("las raices de %dx%c+%dx+%d=0 son:\n\n",a,253,b,c);}}
		
		void formulacuadrarica(int a,int b,int c){
		float x1real,x1img,x2real,x2img;
		if((pow(b,2)-4*a*c)<0){
		x1real=(-b/(float)(2*a));
		x1img=sqrt(-(pow(b,2)-4*a*c))/(2*a);
		x2real=(-b/(float)(2*a));
		x2img=-sqrt(-(pow(b,2)-4*a*c))/(2*a);
		if(x1img<0){
		printf("x1= %.3f+j%.3f \tx2= 5.3f+j%.3f",x1real,-x1img,x2real,x2img);	
		}
		if(x2img<0){
		printf("x1= %.3f+j%.3f \tx2= 5.3f-j%.3f",x1real,x1img,x2real,-x2img);	
		}
	}else{
		x1real=(-b+sqrt(pow(b,2)-4*a*c))/(2*a);
		x2real=(-b-sqrt(pow(b,2)-4*a*c))/(2*a);
		printf("x1= %.3f\tx2= %.3f",x1real,x2real);
	}	
		}
}