View Code of Problem 75

#include<bits/stdc++.h>
using namespace std;
int main() {
	//选择排序进行排序
	int arr[10],t,temp;
	for(int i=0; i<10; i++) cin>>arr[i];
	for(int i=1; i<10; i++) {
		t=i;
		temp=arr[i];
		if(arr[i]<arr[i-1]) {
			for(int j=i-1; j>=0; j--) {
				if(arr[j]>temp) {
					arr[j+1]=arr[j];
					t=j;
				}  
			}
			arr[t]=temp;
		}
	} 
	for(int i=0; i<10; i++) cout<<arr[i]<<endl;
}

Double click to view unformatted code.


Back to problem 75