Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void wprowadzanie(int l[],int r)
  6. {
  7. for(int i=0; i<r; i++)
  8. {
  9. cout<<"Podaj liczbe nr"<<i<<": ";
  10. cin>>l[i];
  11. }
  12. }
  13.  
  14. void sortowanie(int l[],int r)
  15. {
  16. for(int i=0; i<r-1;i++)
  17. {
  18. for(int j=0; j<r-1; j++)
  19. {
  20. if(l[j]>l[j+1])
  21. {
  22. swap(l[j],l[j+1]);
  23. }
  24. }
  25. }
  26. }
  27. void wyswMAKS(int l[])
  28. {
  29. cout<<"Trzy najwieksze liczby to: "<<l[9]<<", "<<l[8]<<", "<<l[7]<<".";
  30.  
  31. }
  32. void wyswMIN(int l[])
  33. {
  34. cout<<"Trzy najmniejsze liczby to: "<<l[0]<<", "<<l[1]<<", "<<l[2]<<".";
  35.  
  36. }
  37.  
  38. int main()
  39. {
  40. int wp[10];
  41. int wybor;
  42. wprowadzanie(wp,10);
  43. sortowanie(wp,10);
  44.  
  45. cout<<"Co chcesz zrobic?"<<endl;
  46. cout<<"_________________________________"<<endl;
  47. cout<<"1. Wyswietl 3 najwieksze liczby."<<endl;
  48. cout<<"2. Wyswietl 3 najmniejsze liczby."<<endl;
  49. cout<<"_________________________________"<<endl;
  50. while(true){
  51. cout<<"Wybierz opcje: ";
  52. cin>>wybor;
  53.  
  54. switch(wybor)
  55. {
  56. case 1:
  57. wyswMAKS(wp);
  58. break;
  59. case 2:
  60. wyswMIN(wp);
  61. break;
  62.  
  63. }
  64. cout<<endl;
  65. }
  66.  
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement