Commit 2da5e37b by Patryk Czarnik

Lekcja 3

parent 557fe5c7
...@@ -4,10 +4,12 @@ using namespace std; ...@@ -4,10 +4,12 @@ using namespace std;
int main() int main()
{ {
cout << "Jak masz na imie?" << endl; double a, b;
string imie; cout << "Podaj pierwszy bok: ";
cin >> imie; cin >> a;
cout << "Witaj " << imie << endl; cout << "Podaj drugi bok: ";
cin >> b;
cout << "Pole prostokata: " << a*b << endl;
cout << "Obwod prostokata: " << 2*a + 2*b << endl;
return 0; return 0;
} }
...@@ -4,12 +4,11 @@ using namespace std; ...@@ -4,12 +4,11 @@ using namespace std;
int main() int main()
{ {
double a, b; cout << "Jak masz na imie?" << endl;
cout << "Podaj pierwszy bok: "; string imie;
cin >> a; cin >> imie;
cout << "Podaj drugi bok: "; cout << "Witaj " << imie << endl;
cin >> b; cout << imie << endl;
cout << "Pole prostokata: " << a*b << endl;
cout << "Obwod prostokata: " << 2*a + 2*b << endl;
return 0; return 0;
} }
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(nullptr));
int x = rand();
int y = rand();
cout << "Wylosowane liczby: " << x << ", " << y << endl;
return 0;
}
#include <iostream>
using namespace std;
/* Zapytaj czlowieka ile ma lat.
Jesli jest pelnoletni, to napisz, ze moze kupic piwo.
Jesli nie, to napisz za ile lat bedzie pelnoletni.
*/
int main()
{
cout << "Ile masz lat? ";
int wiek;
cin >> wiek;
if(wiek < 18) {
cout << "Jestes osoba niepelnoletnia" << endl;
cout << "Osiemnastke bedziesz miec za " << 18 - wiek << " lat." << endl;
} else {
cout << "Jestes dorosly/a i rob co chcesz.";
}
return 0;
}
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(nullptr));
int x = rand() % 10;
int y = rand() % 10;
cout << "Ile to jest " << x << " razy " << y << " ?" << endl;
int odpowiedz;
cin >> odpowiedz;
if(odpowiedz == x*y) {
cout << "Super, jestes madry, bo wiesz jak mnozyc liczby" << endl;
} else {
cout << "Niestety, zla odpowiedz" << endl;
cout << "Wroc do podstawowki!" << endl;
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment