摘要: #include struct ele{ int no; struct ele *link;}main(){ int n,m,i; struct ele *h,*u,*p; clrscr(); printf("Please input n&m:\n"); scanf("%d%d",&n,&m);/*输入n和m*/ h=u=(struct ele *)malloc(sizeof(struct ele));/*形成首表元*/ h->no=1; for(i=2;ilink=(struct ele *)malloc(sizeof(s 阅读全文
posted @ 2014-03-29 22:00 xzenith 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 4 const int N = 256; 5 char buf[N], optr[N]; 6 int opnd[N]; 7 int opndtop,optrtop; 8 9 bool isDigit(char ch)10 {11 return ch >='0' && ch <='9';12 }13 14 int pri(char op)15 {16 if (op=='(') return 0;17 if (op=='+'|| op=='-' 阅读全文
posted @ 2014-03-29 21:45 xzenith 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 1 #include //原来有时候结构体变量不适宜在main函数外申明 2 3 struct date_rec 4 { 5 int day; 6 int month; 7 int year; 8 }; 9 10 struct date_rec current_date;11 12 int days_of_month[][13] = {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}13 };14 1... 阅读全文
posted @ 2014-03-29 21:39 xzenith 阅读(942) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 int check ( long num ) {//只含0-9这十个数,但是2a=b,3a=c 4 int tmp = 0,i = 9, set = 1; 5 while ( i > 0 ) { 6 i--; 7 tmp = num % 10; 8 if ( ( set & ( 1 = 1) { 9 return 0;10 }11 set |= (1 << tmp );12 num = num / 10;13 }1... 阅读全文
posted @ 2014-03-29 17:59 xzenith 阅读(188) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #define N 1000000//差点爆栈long int arr[N];int isPrime(long int n){ int flag=1; long i; if(n%2==0) return 0; for(i=3;i0) ;//printf("%d\t",arr[i]);double dur2=(double)(clock()-b)/CLOCKS_PER_SEC;printf("\n%f\n",dur2);return 0;} 阅读全文
posted @ 2014-03-29 17:42 xzenith 阅读(176) 评论(0) 推荐(0) 编辑
摘要: size_t strlen_d(const char *str) { const char *char_ptr; const ulong *longword_ptr; register ulong longword, himagic, lomagic; for (char_ptr = str; ((ulong)char_ptr & (sizeof(ulong) - 1)) != 0; ++char_ptr) { if (*char_ptr == '\0') return char_ptr -... 阅读全文
posted @ 2014-03-29 17:17 xzenith 阅读(259) 评论(0) 推荐(0) 编辑
摘要: #include #include // 集成最快排序与查找 #define NUM 8int compare(const void *p, const void *q){ return (*(int *)p - *(int *)q);}int main(int argc, char *argv[]){ int array[NUM] = {9, 2, 7, 11, 3, 87, 34, 6}; int key; scanf("%d",&key); int *p; qsort(array, NUM, sizeof(int), compare); ... 阅读全文
posted @ 2014-03-29 17:16 xzenith 阅读(170) 评论(0) 推荐(0) 编辑
摘要: bool RabbinMillerTest( unsigned n ){ if (n>= 1; // 右移一位 r++; // 统计右移的次数 } const unsigned nTestCnt = 8; // 表示进行测试的次数 for ( unsigned i = 0; i < nTestCnt; ++i ) { // 利用随机数进行测试, int a = g_aPrimeList[ rand() % nPrimeListSize ]; if ( 1 != Montgomery( a, m, n ) )... 阅读全文
posted @ 2014-03-29 17:09 xzenith 阅读(163) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include int *primarr, *v;int q = 1, p = 1;//π(n)int pi(int n, int primarr[], int len){ int i = 0, mark = 0; for (i = len - 1; i > 0; i--) { if (primarr[i] n) { if (!mark[j]) s++; j--; ... 阅读全文
posted @ 2014-03-29 17:02 xzenith 阅读(131) 评论(0) 推荐(0) 编辑