摘要: 选择排序(Selection sort)是一种简单直观的排序算法。它的工作原理是:第一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置,然后再从剩余的未排序元素中寻找到最小(大)元素,然后放到已排序的序列的末尾。以此类推,直到全部待排序的数据元素的个数为零。 #include 阅读全文
posted @ 2020-11-11 19:17 code1288 阅读(147) 评论(0) 推荐(0)
摘要: 箱排序,也叫桶排序 (Bucket sort),是一个排序算法,工作的原理是将数组分到有限数量的箱子(桶子)里。每个箱子(桶子)再分别排序。 #include<cstdio> #include<iostream> #include<algorithm> using namespace std; co 阅读全文
posted @ 2020-11-10 19:09 code1288 阅读(196) 评论(0) 推荐(0)
摘要: 【输入格式】 一个整数M 【输出格式】 输出所有小于M 的亲和数对的和 300<=M<=2000000 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 using namespace std; 5 6 const int 阅读全文
posted @ 2020-11-08 20:19 code1288 阅读(149) 评论(0) 推荐(0)
摘要: 质数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数。 最小的质数为2 1 bool panzhi(int x) 2 { 3 if(x<2) 4 { 5 return false; 6 } 7 for(int i=2;i*i<=x;i++) 8 { 9 if(x%i==0) 10 { 阅读全文
posted @ 2020-11-08 19:22 code1288 阅读(83) 评论(0) 推荐(0)
点击右上角即可分享
微信分享提示