Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <cstdio>
- #include <ctime>
- using namespace std;
- int tab[10][10],p1[10],sortedP[10],p;
- int main()
- {
- srand(time(NULL));
- for(int i = 0; i < 10; i++)
- {
- for(int k = 0; k < 10; k++)
- {
- tab[i][k]=rand()%10;
- cout<<tab[i][k];
- }
- cout<<endl;
- }
- for(int i = 0; i < 10; i++)
- {
- p1[i]=tab[i][i];
- }
- for(int i =0 ; i < 10 ; i++)
- cout<<tab[i][i]<<" ";
- cout<<endl;
- for(int i=0;i<10;i++)
- for(int j=1;j<10-i;j++)
- if(p1[j-1]>p1[j])
- swap(p1[j-1], p1[j]);
- for(int i = 0 ; i < 10; i++)
- {
- cout<<p1[i]<<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement