Last active
October 13, 2020 15:18
-
-
Save SantaKrauze/cce9033876d249c298d8 to your computer and use it in GitHub Desktop.
My first piece from '15 :')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <math.h> | |
#include <iostream> | |
using namespace std; | |
int main() //troche pogmatwane, ale idzie sie polapac | |
{ | |
unsigned int a,b,c,kc; | |
cout <<"Podaj dlugosc boku A:" <<endl; | |
cin >>a; | |
if (cin.good()) cout <<"Fantastycznie" <<endl; | |
if (cin.fail()) | |
{//tylko jedna szansa na poprawe:( | |
cout <<"Dozwolone tylko liczby dodatnie" <<endl; | |
cin.clear(); | |
cin.sync(); | |
cin >>a; | |
if (cin.good()) cout <<"Fantastycznie!" <<endl; | |
} | |
cout <<"Podaj dlugosc boku B:" <<endl; | |
cin >>b; | |
if (cin.good()) cout <<"Fantastycznie!" <<endl; | |
if (cin.fail()) | |
{//w obu przypadkach | |
cout <<"Dozwolone tylko liczby dodatnie" <<endl; | |
cin.clear(); | |
cin.sync(); | |
cin >>b; | |
} | |
kc=a*a+b*b; | |
c=sqrt(kc); | |
if (cin.good()) cout <<"Licze" <<endl <<"Wynik wynosi:" <<c <<endl; | |
cout <<"Koniec pracy programu. Nacisnij dowolny klawisz..." <<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment