Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void bezwzgledna()
- {
- int liczba;
- cout << "Podaj liczbe: ";
- cin >> liczba;
- if (liczba>=0)
- {
- cout << "Wartosc bezwzgledna podanej liczby wynosi: " << liczba;
- }
- else if (liczba <0)
- {
- cout << "Wartosc bezwzgledna podanej liczby wynosi: " << -liczba;
- }
- }
- void funkcja()
- {
- int a,b,x;
- cout << "Funkcja ma postac y=ax+b, podaj wartosci czynnikow a i b" << endl;
- cout << "Wprowadz a: ";
- cin >> a;
- cout << "Wprowadz b: ";
- cin >> b;
- if(b==0 && a!=0)
- {
- cout << "Funkcja ma miejsce zerowe dla x=0";
- }
- else if (b==0 && a==0)
- {
- cout << "Funkcja ma nieskończenie wiele miejsc zerowych.";
- }
- else if (a==0)
- {
- cout << "Funkcja nie ma miejsca zerowego";
- }
- else
- {
- x=-b/a;
- cout << "Funkcja ma miejsce zerowe dla x=" << x;
- }
- }
- void choinka()
- {
- int a,b,c,d;
- cout << "Podaj wysokosc choinki: ";
- cin >> a;
- c=-1;
- d=c;
- b=a;
- for(a;a>0;a--)
- {
- b=a-1;
- c=c+2;
- d=c;
- for (b;b>0;b--)
- {
- cout << " ";
- }
- for(d;d>0;d--)
- {
- cout << "*";
- }
- cout << endl;
- }
- }
- void imie()
- {
- string name;
- do
- {
- cout << "Wprowadz imie: ";
- cin >> name;
- }while(name!="Michal");
- cout << "Dobrze!";s
- }
- int main()
- {
- int wybor;
- cout << "1. Wartosc bezwzgledna" << endl;
- cout << "2. Funkcja liniowa" << endl;
- cout << "3. Choinka" << endl;
- cout << "4. Podaj imie" << endl;
- cin >> wybor;
- switch (wybor)
- {
- case 1:
- bezwzgledna();
- break;
- case 2:
- funkcja();
- break;
- case 3:
- choinka();
- break;
- case 4:
- imie();
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement