uva1339
這個題抓住特征就是每個字母出現的次數
正好復習一遍sort
sort 三個引數(起始地址,結束地址(最后一位要排序的地址),排序方法)
int a[10]={9 6 3 8 5 2 7 4 1 0};
手機碼的就不找逗號了
sort(a,a+10);
默認從小到大 從大到小實作方法
bool cmp(int a,int b){
return a>b;
}
sort(a,a+10,cmp);
高級版
struct node {
int a;
int b;
double c;
};
bool cmp(node x,node y){
if(x.a!=y.a)return x.a<y.a;
if(x.b!=y.b)return x.b>y.b;
return x.c>y.c;
}
按a升序 b降序 c降序排列
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/19134.html
標籤:基礎類
上一篇:求救求救
下一篇:紫書第四章函式與遞回
