Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string imie;
- cout << "podaj imie: ";
- cin >> imie;
- int wiek;
- cout << "podaj wiek: ";
- cin >> wiek;
- // sprawdzamy poprawność pobranych danych (czy bufor wejścia nie sygnalizuje błędu)
- while (cin.fail()) // cin.fail() zwraca true jeśli wystąpił błąd odczytu i false jeśli błąd nie wystąpił
- {
- cout << "Wiek zostal podany nieprawidlowo. Wpisz jeszcze raz: ";
- cin.clear(); // opuszczenie flagi błędu (od tego momentu pudełko już nie świeci na czerwono)
- cin.ignore(99999, '\n'); // usunięcie danych z bufora wejścia
- cin >> wiek;
- }
- cout << "czesc " << imie;
- cout << ", masz " << wiek << " lat" << endl;
- if (wiek >= 18)
- {
- cout << "jestes pelnoletnia osoba";
- }
- else
- {
- cout << "jestes osoba niepelnoletnia";
- }
- return 0;
- }
Advertisement
Comments
-
- Your RDP is ready!
- IP: artur-rig.myvnc.com
- Username: artur
- Password: 11221
- How to?
- 1. Click the Start menu from your desktop, and type "remote desktop"
- 2. Put IP in the computer text box.
- 3. Click on show options, change username.
- 4. click connect, type your password.
Add Comment
Please, Sign In to add comment
Advertisement