Here is what i have done so far...
Beacuse i couldnt put the read section in fuction i leave it in main.(I need to functionize it.. HELP!!!)
I did a search (i think :P) in a function that read all the Jumps and it suppose to call it in main and print the Athletes with jumps longer than 7.50
But can't make it work...
And last i have to make in "if" if someone gives negative jump.
Code:
#include <cstdlib>
#include <iostream>
#define MAX_ATHLETES 4
using namespace std;
struct athlete
{
char lastname[40];
float p1,p2,p3,p4;
};
athlete* find_athlete(athlete A[],float p1,p2,p3,p4);
int main(int argc, char *argv[])
{
int i;
athlete A[MAX_ATHLETES];
athlete* ptr;
for(i=0;i<MAX_ATHLETES;i++){
fflush(stdin);
printf("\n*** Give Athletes Data: \n");
printf("Lastname: ");
gets(A[i].lastname);
printf("First Jump: ");
scanf("%f",&A[i].p1);
printf("Second Jump: ");
scanf("%f",&A[i].p2);
printf("Third Jump: ");
scanf("%f",&A[i].p3);
printf("Fourth Jump: ");
scanf("%f",&A[i].p4);
}
printf("Press Enter to Show Athletes with Jumps longer that 750");
system("PAUSE");
return EXIT_SUCCESS;
}
athlete* find_athlete(athlete A[],float p1,p2,p3,p4);
{
int i;
for(i=0;i<MAX_ATHLETES; i++){
if (A[i].p1,p2,p3,p4 > 750)
return &A[i];
}
return NULL;
}