// cs162_422.c
#include <stdio.h>
#include <stdlib.h>
// dummy Random
double Random(double m, double s)
{
return 123.456 * (double) rand() / ((double) RAND_MAX
+ 1.0); }
// main
int main(void)
{
int i, n;
unsigned seed;
double mu, siguma, *array;
int j, length;
double max, min;
const double max_width = 57.0; // 一番長い所の桁数
const char mark = '*'; // ヒストグラムに使う文字
// input & setting
if ((array
= (double *) malloc(sizeof(double) * n
)) == NULL
) { }
// show
for (i = 0; i < n; i++) {
array[i] = Random(mu, siguma);
if (i == 0) {
max = min = array[0];
} else {
if (max < array[i]) {
max = array[i];
}
if (min > array[i]) {
min = array[i];
}
}
}
for (i = 0; i < n; i++) {
printf("[%3d] %10.5f ", i
+ 1, array
[i
]); length = (int) (max_width * array[i] / max);
for (j = 0; j < length; j++) {
}
for (; j < max_width; j++) {
}
printf("|%s\n", max
== array
[i
] ? " MAX" : (min
== array
[i
] ? " min" : "")); }
// end
if (array) {
array = NULL;
}
return 0;
}
Ly8gY3MxNjJfNDIyLmMKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCi8vIGR1bW15IFJhbmRvbQpkb3VibGUgUmFuZG9tKGRvdWJsZSBtLCBkb3VibGUgcykKewogICAgcmV0dXJuIDEyMy40NTYgKiAoZG91YmxlKSByYW5kKCkgLyAoKGRvdWJsZSkgUkFORF9NQVggKyAxLjApOwp9CgovLyBtYWluCmludCBtYWluKHZvaWQpCnsKICAgIGludCBpLCBuOwogICAgdW5zaWduZWQgc2VlZDsKICAgIGRvdWJsZSBtdSwgc2lndW1hLCAqYXJyYXk7CgogICAgaW50IGosIGxlbmd0aDsKICAgIGRvdWJsZSBtYXgsIG1pbjsKICAgIGNvbnN0IGRvdWJsZSBtYXhfd2lkdGggPSA1Ny4wOyAgLy8g5LiA55Wq6ZW344GE5omA44Gu5qGB5pWwCiAgICBjb25zdCBjaGFyIG1hcmsgPSAnKic7ICAgICAgLy8g44OS44K544OI44Kw44Op44Og44Gr5L2/44GG5paH5a2XCgogICAgLy8gaW5wdXQgJiBzZXR0aW5nCiAgICBwcmludGYoIuS5seaVsOezu+WIlyh4KTogIik7CiAgICBzY2FuZigiJXUiLCAmc2VlZCk7CiAgICBwcmludGYoIuWAi+aVsDogIik7CiAgICBzY2FuZigiJWQiLCAmbik7CiAgICBwcmludGYoIuW5s+WdhyjOvCk6ICIpOwogICAgc2NhbmYoIiVsZiIsICZtdSk7CiAgICBwcmludGYoIuWIhuaVoyjPgyk6ICIpOwogICAgc2NhbmYoIiVsZiIsICZzaWd1bWEpOwogICAgc3JhbmQoc2VlZCk7CiAgICBpZiAoKGFycmF5ID0gKGRvdWJsZSAqKSBtYWxsb2Moc2l6ZW9mKGRvdWJsZSkgKiBuKSkgPT0gTlVMTCkgewogICAgICAgIGV4aXQoMSk7CiAgICB9CgogICAgLy8gc2hvdwogICAgcHJpbnRmKCJcbuS5seaVsOihqFxuXG4iKTsKICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBhcnJheVtpXSA9IFJhbmRvbShtdSwgc2lndW1hKTsKICAgICAgICBpZiAoaSA9PSAwKSB7CiAgICAgICAgICAgIG1heCA9IG1pbiA9IGFycmF5WzBdOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGlmIChtYXggPCBhcnJheVtpXSkgewogICAgICAgICAgICAgICAgbWF4ID0gYXJyYXlbaV07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKG1pbiA+IGFycmF5W2ldKSB7CiAgICAgICAgICAgICAgICBtaW4gPSBhcnJheVtpXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBwcmludGYoIlslM2RdICUxMC41ZiAiLCBpICsgMSwgYXJyYXlbaV0pOwogICAgICAgIGxlbmd0aCA9IChpbnQpIChtYXhfd2lkdGggKiBhcnJheVtpXSAvIG1heCk7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGxlbmd0aDsgaisrKSB7CiAgICAgICAgICAgIHByaW50ZigiJWMiLCBtYXJrKTsKICAgICAgICB9CiAgICAgICAgZm9yICg7IGogPCBtYXhfd2lkdGg7IGorKykgewogICAgICAgICAgICBwcmludGYoIiAiKTsKICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJ8JXNcbiIsIG1heCA9PSBhcnJheVtpXSA/ICIgTUFYIiA6IChtaW4gPT0gYXJyYXlbaV0gPyAiIG1pbiIgOiAiIikpOwogICAgfQoKICAgIC8vIGVuZAogICAgaWYgKGFycmF5KSB7CiAgICAgICAgZnJlZShhcnJheSk7CiAgICAgICAgYXJyYXkgPSBOVUxMOwogICAgfQogICAgcmV0dXJuIDA7Cn0=