?? xhpsort.c
字號:
/* Driver for routine hpsort */
#include <stdio.h>
#include <stdlib.h>
#define NRANSI
#include "nr.h"
#include "nrutil.h"
#define MAXSTR 80
#define NP 100
int main(void)
{
char txt[MAXSTR];
int i,j;
float *a;
FILE *fp;
a=vector(1,NP);
if ((fp = fopen("tarray.dat","r")) == NULL)
nrerror("Data file tarray.dat not found\n");
fgets(txt,MAXSTR,fp);
for (i=1;i<=NP;i++) fscanf(fp,"%f",&a[i]);
fclose(fp);
printf("\noriginal array:\n");
for (i=0;i<=9;i++) {
for (j=1;j<=10;j++) printf("%7.2f",a[10*i+j]);
printf("\n");
}
hpsort(NP,a);
printf("\nsorted array:\n");
for (i=0;i<=9;i++) {
for (j=1;j<=10;j++) printf("%7.2f",a[10*i+j]);
printf("\n");
}
free_vector(a,1,NP);
return 0;
}
#undef NRANSI
/* (C) Copr. 1986-92 Numerical Recipes Software . */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -