1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define N 500
float a,b;
float BMI,sumx,x;
int k=0;
int l=0;
int c,d,m,p;
double w[N], h[N];
float high_w,high_h,aveg_w;
void ComputeMetrics(float *weight, float w_count, float &high_w);
void ComputeMetrics(float *weight, float w_count, float &high_w)
{
for(c = 0; c<(k-1);c++)
{
for(d = 0;d<k-c-1;d++)
{
if(w[d]>w[d+1])
{
m = w[d];
w[d] = w[d+1];
w[d+1] = m;
}
}
}
printf("%lf\n",w[c]);
}
int main()
{
FILE *weight;
weight =fopen("1.dat","r");
while(fscanf(weight,"%lf",&w[k])==1)
{
k++;
}
ComputeMetrics(w,k,high_w);
}
|