- //冒泡排序
- private List<Shop> pocektSort(List<Shop> shops)
- {
- int temp;
- for (int i = 0; i < shops.Count; i++)
- {
- for (int j = 0; j < shops.Count - i - 1; j++)
- {
- if (shops[j].Credit < shops[j + 1].Credit)
- {
- temp = shops[j + 1].Credit;
- shops[j + 1] = shops[j];
- shops[j] = temp;
- }
- }
- }
- return shops;
- }
- private int findCredit(Shop shop,List<Shop> shops)
- {//搜索排名
- int i = 1;
- foreach (Shop s in shops)
- {
- if (shop.Credit == s.Credit)
- {
- return i;
- break;
- }
- else
- {
- i++;
- }
- }
- return -1;
- }
冒泡排序
最新推荐文章于 2025-01-10 21:51:58 发布