Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <conio.h>
- #include <string.h>
- #include <windows.h>
- using namespace std;
- double a, b, c, p, ar, bs, alt, maior, menor;
- float ler_a(){
- cout << "\nDigite o valor do lado A: "; cin >> a;
- return 0;
- }
- float ler_b(){
- cout << "Digite o valor do lado B: "; cin >> b;
- return 0;
- }
- float ler_c(){
- cout << "Digite o valor do lado C: "; cin >> c;
- return 0;
- }
- int verifica_triangulo(){
- if(a<(b+c) && b<(a+c) && c<(a+b)){
- cout << "\nEh triangulo!" << endl;
- }
- else{
- cout << "\nNao eh triangulo!" << endl;
- }
- return 0;
- }
- int tipo_triangulo(){
- if(a<(b+c) && b<(a+c) && c<(a+b)){
- if(a==b && a==c && b==c)cout << "\nEquilatero!\n";
- if(a==b || a==c || b==c)cout << "\nIsósceles!\n";
- if(a!=b && a!=c && b!=c)cout << "\nEscaleno!\n";
- }
- return 0;
- }
- float semiperimetro(){
- p = (a+b+c)/2;
- cout << "\nSemiperimetro: " << p << endl;
- return 0;
- }
- float area(){
- ar = sqrt(p*(p-a)*(p-b)*(p-c));
- cout << "\nArea: " << ar << endl;
- return 0;
- }
- float base(){
- if(a==b==c)bs=a;
- else{
- maior = a;
- menor = a;
- if(b<menor)menor=b;
- if(b>maior)maior=b;
- if(c<menor)menor=c;
- if(c>maior)maior=c;
- bs = maior;
- }
- if(a==b)bs=c;
- if(a==c)bs=b;
- if(b==c)bs=a;
- cout << "\nBase: " << bs << endl;
- return 0;
- }
- float altura(){
- alt=(2*ar)/bs;
- cout << "\nAltura " << alt << endl;
- return 0;
- }
- int main ()
- { setlocale(LC_ALL, "Portuguese");
- char tecla = '0';
- while (tecla != 27 )
- { // tela de menu
- system("cls");
- cout << "\n***Menu de Controle***\n \
- \n1-Ler os lados A,B e C: \
- \n2-Verificar se eh triangulo: \
- \n3-Verifica o tipo do triangulo: \
- \n4-Calcular semiperimetro: \
- \n5-Calcular a area: \
- \n6-Identificar a base: \
- \n7-Calcular a altura: \
- \nESC - Finalizar programa: \
- \n\n\nItem:";
- tecla = getch();
- // tratamento do menu
- if (tecla == '1'){
- ler_a();
- ler_b();
- ler_c();
- system("pause");
- }
- else if (tecla =='2'){
- verifica_triangulo();
- system("pause");
- }
- else if (tecla == '3'){
- tipo_triangulo();
- system("pause");
- }
- else if (tecla == '4'){
- semiperimetro();
- system("pause");
- }
- else if (tecla == '5'){
- area();
- system("pause");
- }
- else if (tecla == '6'){
- base();
- system("pause");
- }
- else if (tecla == '7'){
- altura();
- system("pause");
- }
- }// fim do menu
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment