This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "HEDE_FILE" | |
int main() { | |
int *array, i, n; | |
scanf("%d", &n); | |
array = (int *)Malloc( n * sizeof(int) ); | |
for( i = 0; i < n; i ++ ) { | |
scanf("%d", &array[i]); | |
} | |
exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
快速排序算法之所以得到广泛的应用是因为它在很多情况下都能运行的很好,其他方法可能更合适解决某些特定的情况,而快速排序算法可以比其他方法处理更多的排序问题,而且它通常会比其他可选择的方案更快. | |
*/ | |
/* | |
基本快速排序算法 | |
*/ | |
int partition(Item a[], int l, int r); | |
void quicksort(Item a[], int l, int r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef int Item; | |
#define key(A) (A) | |
#define less(A, B) (key(A) < key(B)) | |
#define exch(A, B) { Item t = A; A = B; B = t; } | |
//#define exch(A, B) { A = A^B; B = B ^ A; A = A ^ B; } | |
#define compexch(A, B) if (less(B, A)) exch(A, B) | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Item max(Item a[], int l, int r) | |
{ | |
Item u, v; int m = (l+r)/2; | |
if (l == r) return a[l]; | |
u = max(a, l, m); | |
v = max(a, m+1, r); | |
if (u > v) return u; else return v; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int gcd(int m, int n) { | |
if ( n == 0 ) return m; | |
return gcd(n, m % n); | |
} | |
#include <stdio.h> | |
int main () { | |
printf("%d\n", gcd( 12, 8 ) ); | |
system("pause"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
(x+1)的N次方的多项式 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include "POLY.h" | |
main(int argc, char *argv[]) | |
{ int N = atoi(argv[1]); float p = atof(argv[2]); | |
Poly t, x; int i, j; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define Nmax 10 | |
#define Mmax 20 | |
char buf[Mmax]; | |
int M = 0; | |
int compare(void *i, void *j) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define N 20 | |
main( int argc, char *argv[] ) { | |
int i, j, t; | |
char a[N], *p = argv[1]; | |
for ( i = 0; i < N-1; a[i] = t, i++ ) { | |
if ( (t=getchar()) == EOF ) { | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
链表排序 | |
*/ | |
#include <stdlib.h> | |
typedef struct node* link; | |
struct node | |
{ | |
int item; | |
link next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
link reverse( link x ) { | |
link t, y = x, r = NULL; | |
while ( y != NULL ) { | |
t = y->next; | |
y->next = r; | |
r = y; | |
y = t; | |
} | |
} |
NewerOlder