#include #include #include #define LIMIT_LOW 0 #define LIMIT_HIGH 25 /* 構造体の定義 */ typedef struct tag { int temp; /* 温度 */ struct tag *next; /* 自分自身の型へのポインタ変数 */ } tempData; /* 温度データ */ /* 新データ作成関数 */ tempData *makeNewNode(int t) { tempData *pNewNode; /*** person 型のメモリ領域確保 ***/ pNewNode = (tempData *)malloc(sizeof(tempData)); if (pNewNode != NULL) { /*** データ設定 ***/ pNewNode->temp = t; pNewNode->next = NULL; } return pNewNode; } int main(void) { int temp; /* 温度入力用変数 */ tempData *pTop; /* 温度データリストのトップ */ tempData *pNow; /* 温度データリスト内の現在位置 */ tempData *pNew; /* 温度データの新規データ */ /* 必要であれば,ここに変数を追加 */ int tempSum = 0; int tempConut = 0; /* 最初のデータは,必ず範囲内のデータであるとする */ scanf("%d", &temp); pTop = makeNewNode(temp); pNow = pTop; /* 次のデータを入力 */ scanf("%d", &temp); while ((LIMIT_LOW <= temp) && (temp <= LIMIT_HIGH)) { /* ここにリスト作成処理を記述 */ pNew = makeNewNode(temp); pNow->next = pNew; pNow = pNew; tempSum += temp; tempConut++; /* 次のデータを入力 */ scanf("%d", &temp); } /* ここに平均より大きいデータだけ表示する処理 */ pNow = pTop; double tempAvg = tempSum / tempConut; while (pNow != NULL) { if (tempAvg < pNow->temp) { printf("%d\n", pNow->temp); } pNow = pNow->next; } return 0; }