Skip to content

Instantly share code, notes, and snippets.

@6uclz1
Created October 12, 2015 05:10
Show Gist options
  • Save 6uclz1/b7a4fea728b56b91df7f to your computer and use it in GitHub Desktop.
Save 6uclz1/b7a4fea728b56b91df7f to your computer and use it in GitHub Desktop.
//mondai2
#include <stdio.h>
int main()
{
int i, st_num = 5, ave_height = 0, ave_weight = 0;
int data[st_num][3];
for (int i = 0; i < st_num; ++i)
{
printf("h w ? ");
scanf("%d %d", &data[i][0], &data[i][1]);
ave_height = ave_height + data[i][0];
ave_weight = ave_weight + data[i][1];
data[i][2] = data[i][1] * 10000 / (data[i][0] * data[i][0]);
}
for (int i = 0; i < st_num; ++i)
{
printf("%d %d %d \n", data[i][0], data[i][1], data[i][2]);
}
ave_height = ave_height / st_num;
ave_weight = ave_weight / st_num;
printf("ave height: %d, ave weight: %d \n", ave_height, ave_weight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment