Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1.  
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. int silnia (int x)
  6. {
  7.  
  8. if (x == 0) return 1;
  9. else return x*silnia(x-1);
  10. }
  11.  
  12. int main()
  13. {
  14. int a;
  15. cout << "Obliczanie silni z ";
  16. cout << "Podaj liczbe: ";
  17. cin >> a;
  18. cout << a << "! = " << silnia(a) << endl;
  19. return 0;
  20. }
  21.  
  22. //P.C. IIIA
  23. #include <iostream>
  24. #include <cstdlib>
  25. using namespace std;
  26. void Dane (int &x,float tab[])
  27. {
  28. cout << "Sortowanie liczb rosnaco dowolnych liczb 'bombelkowo' P.C."<<endl;;
  29. cout << "Ile ma byc zbiorow :";
  30. cin >> x;
  31. cout << "Podaj wartosci : "<<endl;
  32. for (int i=0; i<x; i++)
  33. {
  34. cout <<" liczba(" <<i+1<<") =";
  35. cin >>tab[i];
  36. cout << endl;
  37. }
  38. }
  39. void Wypisz (int x, float tab[])
  40. {
  41. for (int i=0; i<x; i++)
  42. cout << tab[i]<< " ";
  43. cout << endl;
  44. }
  45. void Zamiana (float &a, float &b)
  46. {
  47. float temp;
  48. temp=a;
  49. a=b;
  50. b=temp;
  51. }
  52. void Bubble_sort (int x, float tab[])
  53. {
  54. for(int j=0;j<x-1; j++)
  55. for(int i=0; i<x-1;i++)
  56. if (tab[i]> tab[i+1]) Zamiana(tab[i], tab[i+1]);
  57. }
  58. float liczby[20];
  59. int y;
  60. int main()
  61. {
  62. Dane(y,liczby);
  63. Wypisz(y,liczby);
  64. Bubble_sort(y,liczby);
  65. cout << "Liczby uporzadkowane: "<< endl;
  66. Wypisz(y,liczby);
  67. return 0;
  68. }
  69.  
  70. //P.C IIIa
  71. #include<iostream>
  72. #include<string.h>
  73. using namespace std;
  74.  
  75. void zamiana(string &c, string &v)
  76. {
  77. string temp;
  78. temp = c;
  79. c = v;
  80. v = temp;
  81. }
  82. void sortowanie(int x, string tab[])
  83. {
  84. int j, k;
  85. for (int i = 0; i < x; i++)
  86. {
  87. k = i;
  88. for (int j = i; j < x; j++) if (tab[j] < tab[k]) k = j;
  89. zamiana(tab[k], tab[i]);
  90. }
  91. }
  92. void dane(int &x, string tab[])
  93. {
  94. cout << "Podaj ile ma byc imion:";
  95. cin >> x;
  96. cout << endl;
  97. for (int i = 0; i < x; i++)
  98. {
  99. cout << "Podaj Imie " << i + 1 << ":";
  100. cin >> tab[i];
  101. cout << endl;
  102. }
  103. }
  104. void wypisz(int x, string tab[])
  105. {
  106. for (int i = 0; i < x; i++)
  107. {
  108. cout << tab[i] << " ";
  109. }
  110. }
  111. void kobiety(int n, string lel[])
  112. {
  113. cout << endl;
  114. cout << "kobiety:";
  115. int index;
  116. string imie;
  117. for (int i = 0; i < n; i++)
  118. {
  119. imie = lel[i];
  120. index = lel[i].length() - 1;
  121. if (imie[index] == 'a')
  122. cout << lel[i] << " ";
  123.  
  124. }
  125. }
  126. void mezczyzni(int n, string lel[])
  127. {
  128. cout << endl;
  129. cout << "mezczyzni: ";
  130. int index;
  131. string imie;
  132. for (int i = 0; i < n; i++)
  133. {
  134. imie = lel[i];
  135. index = lel[i].length() - 1;
  136. if (imie[index] != 'a')
  137. cout << lel[i] << " ";
  138.  
  139. }
  140. }
  141. string slowa[20];
  142. int n;
  143. int main()
  144. {
  145. dane(n, slowa);
  146. wypisz(n, slowa);
  147. sortowanie(n, slowa);
  148. cout << endl << endl;
  149. cout << "Imiona ulozone alfabetycznie :" << " ";
  150. wypisz(n, slowa);
  151. kobiety(n, slowa);
  152. mezczyzni(n, slowa);
  153. return 0;
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement