摘要: 1 #include <iostream> 2 using namespace std; 3 4 bool isprime(int a){ 5 6 if(a<=1) return false; 7 8 for(int i=2;i*i<=a;i++){ 9 if(a%i==0) return fals 阅读全文
posted @ 2020-02-23 19:32 xuecl 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 4 //最大公约数 5 int gcd(int a,int b){ 6 return b?gcd(b,a%b):a; 7 } 8 9 //最小公倍数 10 int lcm(int a,int b){ 11 阅读全文
posted @ 2020-02-23 16:47 xuecl 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 4 void swap(int* a,int* b){ 5 int temp = 0; 6 temp = *a;*a=*b;*b=temp; 7 } 8 9 void qsort(int arr[],int 阅读全文
posted @ 2020-02-23 15:41 xuecl 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 using namespace std; 3 const int maxn = 100; 4 5 int merge(int A[],int L1,int R1,int L2,int R2){//L1、R1为第一段区间的左下标与右下标,同理L2、R2 阅读全文
posted @ 2020-02-23 14:50 xuecl 阅读(234) 评论(0) 推荐(0) 编辑