上一页 1 2 3 4 5 6 7 8 ··· 12 下一页
摘要: #include #include int ttj(int n){ int n1; int n2; if(n == 1) return 1; if(n == 2) return 2; n1 = ttj(n - 1); n2 = ttj(n - 2); return n2 + n1;}main(){ int num; num = ttj(3); printf("%d",num);} 阅读全文
posted @ 2014-03-03 10:53 yutoulck 阅读(107) 评论(0) 推荐(0) 编辑
摘要: #include #include swap(char* str, int b, int e){ char temp = str[b]; str[b] = str[e]; str[e] = temp;}print(char* str, int n){ int i; for(i = 0; i< n; i++){ printf("%c ", str[i]); } printf("\n");}int quanXuLie(char* str, int b, int n){ int i; if(n <= 1){ print... 阅读全文
posted @ 2014-03-03 10:39 yutoulck 阅读(154) 评论(0) 推荐(0) 编辑
摘要: #include #include typedef struct Node{ int content; struct Node* next;}LNode;init(LNode** head){ *head = (LNode*)malloc(sizeof(LNode)); (*head)->content = 0; (*head)->next = NULL;}insert(LNode* head, int num){ LNode* newNode = (LNode*)malloc(sizeof(LNode)); newNode -> content = ... 阅读全文
posted @ 2014-03-03 09:27 yutoulck 阅读(256) 评论(0) 推荐(0) 编辑
摘要: #include find(char* str, int n){ int i = 1; char temp = str[0]; int num = 1; while(i < n){ if(str[i] == temp){ num++; } else if(num == 0){ temp = str[i]; num = 0; } else{ num--; } i++; } pr... 阅读全文
posted @ 2014-03-03 09:01 yutoulck 阅读(121) 评论(0) 推荐(0) 编辑
摘要: #include getNext(char str[],int n, int next[]){ int i, j; i = 1; j = 0; next[0] = -1; next[1] = 0; while(i < n){ if(str[i] == str[j]){ i++; j++; next[i] = j; } else if(j == 0){ i++; next[i] = 0; } ... 阅读全文
posted @ 2014-02-26 16:30 yutoulck 阅读(164) 评论(0) 推荐(0) 编辑
摘要: #include int find(int num[], int b, int e){ int temp = num[b]; int i = b; int j = e; while(i temp) j--; if(i b){ kp(num, b, n - 1); } if(n < e){ kp(num, n + 1, e); }}main(){ int i; int num[] = {1, -2, 3, 10, -4, 7, 2, -5,}; kp(num, 0, 7); for(i... 阅读全文
posted @ 2014-02-26 16:09 yutoulck 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 求和最大的数字组合。findMax(int num[], int n){ int i; int b = 0; int e = 0; int tb = 0; int te = 0; int total = 0; int temp = 0; for(i = 0; i num[i]){ temp = temp + num[i]; te = i; } else{ tb = i; te = i; temp = num[... 阅读全文
posted @ 2014-02-25 19:13 yutoulck 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 在给定数字范围内,求和为某数的全部组合#include struct Zhan{ int n; int content[100];};ruZhan(struct Zhan* zhan, int x){ (*zhan).content[(*zhan).n] = x; (*zhan).n++;}czZhan(struct Zhan* zhan, int n){ (*zhan).n = n;}printfZhan(struct Zhan* zhan){ int i; for(i = 0; i 0){ ruZhan(zhan, e); ... 阅读全文
posted @ 2014-02-25 15:26 yutoulck 阅读(336) 评论(0) 推荐(0) 编辑
摘要: 给定排好序的数字,求和为某数的两个数字组合。#include struct Pair{ int f; int s;} ;int find(int num[], int n, int x, struct Pair pairs[]){ int i = 0; int j = n - 1; int m = 0; for(; i x) j--; else{ pairs[m].f = num[i]; pairs[m].s = num[j]; i++; j--; ... 阅读全文
posted @ 2014-02-25 14:54 yutoulck 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 使用了堆排序,因为没有必要将全部排好序,堆排序恰好符合要求。#include init(int num[], int n){ int h, i; if(n 0){ creatHeap(num, n, h); i--; if((i - 1) / 2 == h) i--; h = (i - 1) / 2;//下一个非叶结点 }}//整理非叶结点的堆creatHeap(int num[], int n, int h){ int temp = num[h];//临时存放数据 int i;//指示叶结点 int... 阅读全文
posted @ 2014-02-25 11:41 yutoulck 阅读(620) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 12 下一页