Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cmath>
  4. #include <iomanip>
  5.  
  6.  
  7.  
  8. using namespace std;
  9. const int N=10;
  10. int main()
  11. {
  12. int d[N],pmin,j,i,a;
  13.  
  14.  
  15. cout<<"Sortowanie przez wybór"<<endl;
  16. cout<<"Podaj ile liczb chcesz wprowadziæ "<<endl;
  17.  
  18.  
  19. cout<<"Przed sortowaniem"<<endl;
  20.  
  21. for (i=0;i<N;i++)
  22. {
  23. cout<<"wprowadz liczbe -10 liczb";
  24. cin>>d[i];
  25. }
  26.  
  27. for (i=0;i<N;i++) cout<<setw(4)<<d[i];
  28. cout<<endl;
  29.  
  30. for (j=0;j<N-1;j++)
  31. {
  32. pmin=j;
  33. for (i=j+1;i<N;i++)
  34. if(d[i]<d[pmin]) pmin=i;
  35. swap(d[pmin],d[j]);
  36. }
  37.  
  38. cout<<"Po sortowaniu \n\n";
  39. for (i=0;i<N;i++) cout<<setw(4)<<d[i];
  40. cout<<endl;
  41. return 0;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement