View Code of Problem 76

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
bool cmp(int a,int b){
	return a>b; //a>b a在前 
}
int main(){
	int ss[10];
	bool flag=true;//默认从小到大 
	for(int i=0;i<10;i++){
		cin>>ss[i];
	}
	if(ss[0]>ss[1])
		flag=false;
	if(flag)
		sort(ss,ss+10);
	else
		sort(ss,ss+10,cmp);

	for(int i=0;i<10;i++){
		cout<<ss[i]<<endl;
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 76