ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Programa(ecuacion De Segundo Grado)


Enviado por   •  17 de Marzo de 2014  •  437 Palabras (2 Páginas)  •  330 Visitas

Página 1 de 2

/*P10Ec2do.cpp*/

#include<iostream>

#include<cstdlib>

#include<cstring>

#include<cmath>

#include"gotoxy.h"

using namespace std;

void let();

void ent(float*,float*,float*);

void proc(float,float,float,float*,float*,float*,float*);

void sal(float,float,float,float);

int main(){

float a,b,c,r1,r2,i1,i2;

char opc;

while(1){

ent(&a,&b,&c);

proc(a,b,c,&r1,&r2,&i1,&i2);

sal(r1,r2,i1,i2);

while(2){

gotoxy(40,20);

cout<<"Otro proceso (S/N)?: ";

cin>>opc;

opc=tolower(opc);

if(opc=='s' || opc=='n')break;

}

if(opc=='n')break;

}

return 0;

}

void ent(float*a,float*b,float*c){

let();

gotoxy(10,9);

cout<<"Alimentar a: ";

cin>>*a;

gotoxy(10,10);

cout<<"Alimentar b: ";

cin>>*b;

gotoxy(10,11);

cout<<"Alimentar c: ";

cin>>*c;

}

void proc(float a,float b,float c,float*r1,float*r2,float*i1,float*i2){

float d;

*i1=*i2=0;

if(a==0){

*r1=*r2=-c/b;

return;

}

d=(b*b)-(4*a*c);

if(d>=0){

*r1=(-b+sqrt(d))/(2*a);

*r2=(-b-sqrt(d))/(2*a);

return;

}

*r1=*r2=-b/(2*a);

*i1=sqrt(-d)/(2*a);

*i2=-*i1;

return;

}

void sal(float r1,float r2,float i1,float i2){

gotoxy(10,15);

cout<<"Resultado";

gotoxy(10,17);

cout<<"X1="<<r1<<"\t"<<i1<<"i";

gotoxy(50,17);

cout<<"X2="<<r2<<"\t"<<i2<<"i";

}

void let(){

char t1[]="INSTITUTO POLITECNICO NACIONAL";

char t2[]="ESCUELA SUPERIOR DE INGENIERIA MECANICA Y ELECTRICA";

char t3[]="IE-2EM5";

char t4[]="ECUACION DE 2do GRADO";

system("cls");

gotoxy((80-strlen(t1))/2,1);

cout<<t1;

gotoxy((80-strlen(t2))/2,2);

cout<<t2;

gotoxy((80-strlen(t3))/2,3);

cout<<t3;

gotoxy((80-strlen(t4))/2,5);

cout<<t4;

}

...

Descargar como  txt (1.9 Kb)  
Leer 1 página más »
txt