Last active
November 29, 2023 14:42
-
-
Save PoetaKodu/5153164274fb43d706d0aa6c4954e879 to your computer and use it in GitHub Desktop.
Pole trapezu i zadanie domowe, kody programów z filmu https://youtu.be/nh-AeItoGac
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 <iostream> | |
int main() | |
{ | |
float a = 15; | |
float b = 10; | |
float h = 5; | |
std::cout << "PROGRAM OBLICZAJĄCY POLE TRAPEZU\n"; | |
std::cout << "Podaj wartość a: "; | |
std::cin >> a; | |
std::cout << "Podaj wartość b: "; | |
std::cin >> b; | |
std::cout << "Podaj wartość h: "; | |
std::cin >> h; | |
if (a > 0 and b > 0 and h > 0) | |
{ | |
std::cout << "Pole trapezu o:\n"; | |
std::cout << "a = " << a << "\n"; | |
std::cout << "b = " << b << "\n"; | |
std::cout << "h = " << h << "\n"; | |
std::cout << "wynosi: "; | |
std::cout << (a + b) * h / 2; | |
} | |
else | |
{ | |
std::cout << "Wszystkie wartości muszą być dodatnie!\n"; | |
} | |
} |
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 <iostream> | |
int main() | |
{ | |
// Aktualny rok na moment pisania programu | |
int currentYear = 2019; | |
// inicjalizuje przykładową wartością | |
int yearOfBirth = 1999; | |
std::cout << "POWIEM CI CZY JESTEŚ PEŁNOLETNI\n"; | |
std::cout << "Podaj rok urodzenia: "; | |
std::cin >> yearOfBirth; | |
if (currentYear - yearOfBirth >= 18) | |
{ | |
std::cout << "Jesteś pełnoletni!" << std::endl; | |
} | |
else | |
{ | |
std::cout << "Nie jesteś pełnoletni!" << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
można to tak zrobić?
#include
int main()
{
float a = 10;
std::cout<<"program stwierdzajacy czy jestes pelnoletni \n";
std::cout<<"podaj swoj wiek w liczbie : ";
std::cin>>a;
if(a>=18)
{
std::cout<<"jestes pelnoletni";
}
else
{
std::cout<<"jestes niepelnoletni";
}
}