int arr[]={18,4,13,-1,2,7,19,14,11,0,-9,9,4,2,-2,-7,18,18,-7,-5,9,6,-8,3,13,0,15,9,10,-1,17,13,13,-8,3,8,4,19,10,-8,18,15,11,13,11,1,14,2,10,1,11,5,18,5,-8,13,-10,5,-8,-9,-5,9,10,-10,-3,-3,-4,-4,-8,-10};
int temp=0;
for(int i=0;i<sizeof(arr)/sizeof(int)-1;i++)
{
for(int j=0;j<sizeof(arr)/sizeof(int)-1-i;j++)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
for(auto i=0;i<sizeof(arr)/sizeof(int);i++)
{
cout<<arr[i]<<endl;
}
result:
-10
-8
-4
-4
-3
-3
-10
10
9
-5
-9
-8
5
-10
13
-8
5
18
5
11
1
10
2
14
1
11
13
11
15
18
-8
10
19
4
8
3
-8
13
13
17
-1
10
9
15
0
13
3
-8
6
9
-5
-7
18
18
-7
-2
2
4
9
-9
0
11
14
19
7
2
-1
13
4
18
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)