//
// 得点の平均値と標準偏差,偏差値を求めるプログラム
//
#include <stdio.h>
#include <math.h>

#define MAX_NR_DATA 100	// データの最大個数

int main(void)
{
    int x[MAX_NR_DATA];
    int n = 10;

// 得点を配列に代入する
    x[0] = 10;  x[1] = 69;  x[2] = 50;  x[3] = 30;  x[4] = 45;
    x[5] = 90;  x[6] = 80;  x[7] = 100; x[8] = 78;  x[9] = 85;

// 平均値を求める
    double s = 0.0;
    for (int i = 0; i < n; i ++) {
      s += x[i];
    }
    double xb = s / n;
    printf("平均値  %6.2f\n", xb);

// 標準偏差を求める
    s = 0.0;
    for (int i = 0; i < n; i ++) {
      s += (x[i] - xb) * (x[i] - xb);
    }
    double xs = sqrt(s / n);
    printf("標準偏差 %6.2f\n", xs);
    printf("\n");

// 各得点に対する偏差値を求める
    printf("番号 得点 偏差値\n");
    for (int i = 0; i < n; i ++) {
      s = 50.0 + (x[i] - xb) / xs * 10.0;
      printf("%2d:   %4d  %6.2f\n", i, x[i], s);
    }
}