#include <stdio.h> #include <stdlib.h> #include <time.h> typedef struct{ int no; int age; int height; int weight; int bmi; }person; int main() { srand((unsigned)time(NULL)); int i; person member[10]; for(i = 0; i < 10; i++){ member[i].no = i; member[i].age = rand() % 51 + 10; member[i].height = rand() % 41 + 140; member[i].weight = rand() % 31 + 40; member[i].bmi = calc(member[i].height, member[i].weight); } } int calc(int shincho, int taiju) { return taiju * 10000 / (shincho * shincho); } キーボードから入力された値より大きい bmi の配列要素の no を表示するプログラムを追加.
def calc(shincho, taiju): return taiju * 10000 / (shincho * shincho) calc(170, 60)