1.线性表链式存储
https://github.com/BodhiXing/Data_Structure
2.素数对猜想
https://pta.patest.cn/pta/test/17/exam/4/question/261
思路:查找小于N的素数,存入数组,若相邻的相差2,则计数加1。
1 #include <stdio.h> 2 #include <math.h> 3 4 #define MAX 100000 5 int a[MAX]; 6 7 /*是否为素数*/ 8 int Is_Prime(int n) 9 { 10 int ret = 1; 11 int i; 12 for(i=2;i<=sqrt(n);i++) 13 { 14 if(n%i == 0) 15 { 16 ret = 0; 17 break; 18 } 19 } 20 return ret; 21 } 22 23 void func(int n) 24 { 25 int num = a[0]; 26 int index = 1,count = 0; 27 for(num;num < n;) 28 { 29 num += 2; 30 if(Is_Prime(num)) 31 { 32 a[index] = num; 33 if(a[index]-a[index-1] == 2) 34 count++; 35 index++; 36 } 37 38 } 39 40 printf("%d",count); 41 } 42 43 int main() 44 { 45 int n; 46 scanf("%d",&n); 47 a[0]=3; 48 func(n); 49 }