Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using namespace std;
  2.  
  3. void moja_funkcja()
  4. {
  5. cout << "[1] - dodawanie" << endl;
  6. cout << "[2] - odejmowanie" << endl;
  7. cout << "[0] - wyjscie z programu" << endl <<endl ;
  8. }
  9.  
  10. void dodawanie()
  11. {
  12. int x;
  13.  
  14. cout << "podaj liczbe z zakresu od 100 do 200: ";
  15. cin >> x;
  16.  
  17. if ((x<100) && (x>200))
  18. cout << "liczba nie jest w zakresie" << endl;
  19.  
  20. else if (x<150)
  21. cout <<"liczba jest mala" << endl;
  22.  
  23. else if ((x<175) && (x>150))
  24. cout <<"liczba jest srednia" << endl;
  25.  
  26. else
  27. cout << "liczba jest duza" << endl;
  28.  
  29.  
  30. }
  31.  
  32. void odejmowanie()
  33. {
  34. string liczba;
  35. cout<< endl<< "Podaj dowolna liczbe naturalna: " << endl;
  36. cin >> liczba;
  37. int dl=liczba.length();
  38.  
  39. int m=liczba[0];
  40. for (int i=1; i<=dl; i++)
  41. {
  42. if (liczba[i]>m) m=liczba[i];
  43. }
  44. cout<<"Dlugosc liczby: "<<dl<<endl;
  45. cout<<"Maksymalna cyfra: "<<(char)m<<endl;
  46.  
  47. }
  48.  
  49. int main()
  50. {
  51. cout << "W programie sa dostepne nastepujace opcje:" << endl;
  52. moja_funkcja();
  53. cout << "Wybierz jedna z nich, wpisujacz liczbe i klikajac enter" << endl << endl;
  54. int liczba;
  55. do
  56. {
  57. cin >> liczba;
  58. switch (liczba)
  59. {
  60. case 1:
  61. dodawanie();
  62. break;
  63. case 2:
  64. odejmowanie();
  65. break;
  66. default:
  67. break;
  68. } //switch
  69. } while (liczba != 0);
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement