Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int dodawanie(int a, int b)
  7. {
  8. return a + b;
  9. }
  10.  
  11. void wypiszDo(int max)
  12. {
  13. for(int i=0; i<=max; i++)
  14. {
  15. cout << i << endl;
  16. }
  17. }
  18.  
  19. void Wypisz(vector<int> tab)
  20. {
  21. for(int i=0; i<tab.size(); i++)
  22. {
  23. cout << tab[i] << endl;
  24. }
  25. }
  26.  
  27. void wypiszGwiazdeczki(int max)
  28. {
  29. for(int i=0; i<max; i++)
  30. {
  31. for(int j=0; j<i+1; j++)
  32. {
  33. cout << "*";
  34. }
  35. cout << endl;
  36. }
  37. }
  38.  
  39. bool czyParzysta(int b)
  40. {
  41. if(b%2==0)
  42. {
  43. return true;
  44. }
  45. else
  46. {
  47. return false;
  48. }
  49. }
  50.  
  51. int minimum(vector<int> tab)
  52. {
  53. int wynik;
  54. wynik=tab[0];
  55. for(int i=0; i<tab.size(); i++)
  56. {
  57. if(tab[i]<wynik)
  58. {
  59. wynik=tab[i];
  60. }
  61. }
  62. return wynik;
  63. }
  64.  
  65. bool czyNalezy(vector<int> tab, int liczba)
  66. {
  67. for(int i=0; i<tab.size(); i++)
  68. {
  69. if(tab[i]==liczba)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76.  
  77. bool czyZawiera(vector<int>tab, vector<int>tabu)
  78. {
  79. for(int i=0; i<tabu.size(); i++)
  80. {
  81. if(czyNalezy(tab, tabu[i])==0)
  82. {
  83. return false;
  84. }
  85. }
  86. return true;
  87. }
  88.  
  89. int main()
  90. {
  91. int c = dodawanie(54,45);
  92. cout << c << endl;
  93.  
  94. wypiszDo(15);
  95. wypiszGwiazdeczki(8);
  96. czyParzysta(7);
  97.  
  98. vector<int> tab(3);
  99. tab[0]=5;
  100. tab[1]=3;
  101. tab[2]=8;
  102. Wypisz(tab);
  103. cout << minimum(tab) << endl;
  104. cout << czyNalezy(tab, 5) << endl;
  105.  
  106. vector<int> tabu(2);
  107. tabu[0]=7;
  108. tabu[1]=8;
  109. tabu[1]=5;
  110. cout << czyZawiera(tab, tabu) << endl;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement