Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <cstdio>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7. int tab[10][10],p1[10],sortedP[10],p;
  8.  
  9. int main()
  10. {
  11. srand(time(NULL));
  12. for(int i = 0; i < 10; i++)
  13. {
  14.  
  15. for(int k = 0; k < 10; k++)
  16. {
  17. tab[i][k]=rand()%10;
  18. cout<<tab[i][k];
  19. }
  20. cout<<endl;
  21. }
  22.  
  23. for(int i = 0; i < 10; i++)
  24. {
  25. p1[i]=tab[i][i];
  26. }
  27.  
  28. for(int i =0 ; i < 10 ; i++)
  29. cout<<tab[i][i]<<" ";
  30.  
  31. cout<<endl;
  32.  
  33. for(int i=0;i<10;i++)
  34. for(int j=1;j<10-i;j++)
  35. if(p1[j-1]>p1[j])
  36. swap(p1[j-1], p1[j]);
  37.  
  38. for(int i = 0 ; i < 10; i++)
  39. {
  40.  
  41. cout<<p1[i]<<" ";
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement