Skip to content

Instantly share code, notes, and snippets.

@SantaKrauze
Last active October 13, 2020 15:18
Show Gist options
  • Save SantaKrauze/cce9033876d249c298d8 to your computer and use it in GitHub Desktop.
Save SantaKrauze/cce9033876d249c298d8 to your computer and use it in GitHub Desktop.
My first piece from '15 :')
#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