-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.cpp
More file actions
40 lines (38 loc) · 780 Bytes
/
3.cpp
File metadata and controls
40 lines (38 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <std_lib_facilities.h>
#include <iostream>
using namespace std;
int main()
{
int n;
cin >>n;
int *p = new int [n];
for (int r=0;r<n;r++)
p[r]=rand();
int *k = &p[0];
int *d = &p[0];
for (int i=0;i<n;i++){
cout << *d <<endl;
d+=1;
}
d-=n;
for (int j=0;j<n;j++){
for (int i=0;i<n;i++){
if (*d>*k){
//cout << *d <<" "<<*k<<endl;
swap(*d,*k);
//cout << *d <<" "<<*k<<endl;
}
k+=1;
}
k-=n;
d+=1;
}
d-=n;
cout <<endl<<endl;
for (int i=0;i<n;i++){
cout << *d <<endl;
d+=1;
}
return 0;
delete [] p;
}