histogram.c

来自「该文件为c++的数学函数库!是一个非常有用的编程工具.它含有各种数学函数,为科学」· C语言 代码 · 共 43 行

C
43
字号
#include <stdio.h>#include <stdlib.h>#include <gsl/gsl_histogram.h>intmain (int argc, char **argv){  double a, b;  size_t n;  if (argc != 4)    {      printf ("Usage: gsl-histogram xmin xmax n\n"              "Computes a histogram of the data "              "on stdin using n bins from xmin "              "to xmax\n");      exit (0);    }  a = atof (argv[1]);  b = atof (argv[2]);  n = atoi (argv[3]);  {    double x;    gsl_histogram * h = gsl_histogram_alloc (n);                gsl_histogram_set_ranges_uniform (h, a, b);    while (fscanf (stdin, "%lg", &x) == 1)      {        gsl_histogram_increment (h, x);      }    gsl_histogram_fprintf (stdout, h, "%g", "%g");    gsl_histogram_free (h);  }    exit (0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?