Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <conio.h>
- #include "windows.h"
- #include <time.h>
- using namespace std;
- void menu()
- {
- cout<<"MENU:"<<endl;
- cout<<"1. Kwadrat"<<endl;
- cout<<"2. Prostokat"<<endl;
- cout<<"3. Trojkat"<<endl;
- cout<<"4. Kolo"<<endl;
- }
- int kwad()
- {
- int a;
- cout<<"Wprowadz bok kwadratu: ";
- cin>>a;
- cout<<"Pole kwadratu: "<<a*a<<endl;
- cout<<"Obwod kwadratu: "<<4*a<<endl<<endl;
- }
- int pros()
- {
- int a, b;
- cout<<"Wprowadz pierwszy bok prostokata: ";
- cin>>a;
- cout<<"Wprowadz drugi bok prostokata: ";
- cin>>b;
- cout<<"Pole prostokata: "<<a*b<<endl;
- cout<<"Obwod Prostokata: "<<(2*a)+(2*b)<<endl<<endl;
- }
- int troj()
- {
- int a, b, c, d;
- cout<<"Wprowadz pierwszy bok trojkata: ";
- cin>>a;
- cout<<"Wprowadz drugi bok trojkata: ";
- cin>>c;
- cout<<"Wprowadz trzeci bok trojkata: ";
- cin>>d;
- cout<<"Wprowadz wysokosc trojkata: ";
- cin>>b;
- cout<<"Pole trojkata: "<<0.5*a*b<<endl;
- cout<<"Obwod trojkata: "<<a+c+d<<endl<<endl;;
- }
- int kolo()
- {
- int a;
- cout<<"Wprowadz promien kola: ";
- cin>>a;
- cout<<"Pole kola: "<<3.14*a*a<<endl;
- cout<<"Obwod kola: "<<2*3.14*a<<endl<<endl;;
- }
- int main(int argc, char *argv[])
- {
- char yn;
- int opt;
- do
- {
- system("CLS");
- menu();
- int men = getch();
- switch( men )
- {
- case '1':
- system("CLS");
- kwad();
- break;
- case '2':
- system("CLS");
- pros();
- break;
- case '3':
- system("CLS");
- troj();
- break;
- case '4':
- system("CLS");
- kolo();
- break;
- default:
- system("CLS");
- cout<<"Nie ma takiej opcji!"<<endl;
- break;
- }
- cout<<"Jeszcze raz? (y/n)";
- yn=getch();
- cout<<endl;
- }while(yn!='n');
- return 0;
- //system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement