Clasified in Homeworks of Computers of Bachelor.
Written at June 14, 2010 on
English with a size of 3,835 bytes.
MAIN
#include <cstdlib>
#include <iostream>
#include <string>
#include "triangulo.h"
using namespace std;
int main()
{
triangulo tri;
double areat,peri;
string nomet;
tri.setladoa(5);
tri.setladob(4);
tri.setladoc(9);
peri=tri.perimetro(peri);
areat=tri.area(areat);
tri.classifica(nomet);
cout << "Lado a :"<< tri.getladoa()<<endl;
cout << "Lado b :"<< tri.getladob()<<endl;
cout << "Lado c :"<< tri.getladoc()<<endl;
cout << "Perimetro:"<< peri<<endl;
cout << "Area :"<< areat<<endl;
tri.classifica(nomet);
system("PAUSE");
return EXIT_SUCCESS;
}
.H
#ifndef TRIANGULO_H
#define TRIANGULO_H
#include <iostream>
#include <string>
using namespace std;
class triangulo
{
private:
double a;
double b;
double c;
string nome;
public:
void triangulo::setladoa(double la);
void triangulo::setladob(double lb);
void triangulo::setladoc(double lc);
double getladoa();
double getladob();
double getladoc();
double area(double y);
double perimetro(double x);
void classifica(string n);
};
#endif
.CPP
#include <cstdlib>
#include <iostream>
#include "triangulo.h"
#include <cmath>
#include <string>
using namespace std;
void triangulo::setladoa(double la)
{
a = la;
}
void triangulo::setladob(double lb)
{
b = lb;
}
void triangulo::setladoc(double lc)
{
c = lc;
}
double triangulo::getladoa()
{
return a;
}
double triangulo::getladob()
{
return b;
}
double triangulo::getladoc()
{
return c;
}
double triangulo::area(double y)
{
double sp;
sp=(a+b+c)/2;
y=sqrt(sp*(sp-a)*(sp-b)*(sp-c));
return y;
}
double triangulo::perimetro(double x)
{
x=a+b+c;
return x;
}
void triangulo::classifica(string n)
{
double aux;
if(a<b)
{
aux=a;
a=b;
b=aux;
}
if(a<c)
{
aux=a;
a=c;
c=aux;
}
n="retangulo";
nome=n;
cout<<"Classificacao"<<endl;
if(a*a==b*b+c*c)
cout << "retangulo" <<endl;
if(a*a<b*b+c*c)
cout << "acutangulo" <<endl;
if(a*a>b*b+c*c)
cout << "obtuzangulo" <<endl;
};
| Did you this document helpful? | ||
|---|---|---|
| 0 visitors likes this document. | 0% | |
| 0 visitors dislike this document. | ||
| Tags:logic,double,#include,void,tri,lt;< | |
| This document has been visited 1 times and has received 0 votes |