Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- void moja_funkcja()
- {
- cout << "[1] - dodawanie" << endl;
- cout << "[2] - odejmowanie" << endl;
- cout << "[0] - wyjscie z programu" << endl <<endl ;
- }
- void dodawanie()
- {
- int x;
- cout << "podaj liczbe z zakresu od 100 do 200: ";
- cin >> x;
- if ((x<100) && (x>200))
- cout << "liczba nie jest w zakresie" << endl;
- else if (x<150)
- cout <<"liczba jest mala" << endl;
- else if ((x<175) && (x>150))
- cout <<"liczba jest srednia" << endl;
- else
- cout << "liczba jest duza" << endl;
- }
- void odejmowanie()
- {
- string liczba;
- cout<< endl<< "Podaj dowolna liczbe naturalna: " << endl;
- cin >> liczba;
- int dl=liczba.length();
- int m=liczba[0];
- for (int i=1; i<=dl; i++)
- {
- if (liczba[i]>m) m=liczba[i];
- }
- cout<<"Dlugosc liczby: "<<dl<<endl;
- cout<<"Maksymalna cyfra: "<<(char)m<<endl;
- }
- int main()
- {
- cout << "W programie sa dostepne nastepujace opcje:" << endl;
- moja_funkcja();
- cout << "Wybierz jedna z nich, wpisujacz liczbe i klikajac enter" << endl << endl;
- int liczba;
- do
- {
- cin >> liczba;
- switch (liczba)
- {
- case 1:
- dodawanie();
- break;
- case 2:
- odejmowanie();
- break;
- default:
- break;
- } //switch
- } while (liczba != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement