Given 3 arrays,one accepting Strings the rest integers,lets say:A1[ ],A2[ ],A3[ ].
We get the difference of each element of A2[ ] and A3[ ] to a previously define values.
take for example this code:
//preference.c
#include<stdio.h>
#include<string.h>
typedef char * string; //for STRINGS
char name;
int test; // number of test cases
int HEIGHT,WEIGHT; //for solenn
int suitors; //number of suitors
string suitor_names[0];
int suitor_h[0];
int suitor_w[0];
void sort(){
}
int main(){
//scanf("%d",&test);{} //for test cases later
scanf("%d%d",&HEIGHT,&WEIGHT); //get solenn
scanf("%d",&suitors); //get number of suitors
string suitor_names[suitors]; // Make #ofsuitors strings
suitor_h[suitors];
suitor_w[suitors];
int i,w,h;
for (i = 0; i < suitors; i++)
{
scanf("%s",&name);
suitor_names[i] = name;
scanf("%d%d",&h,&w);
suitor_h[i] = h ;
suitor_w[i] = w ;
}
int j,k,l;
for(j=0;j<suitors-1;j++){
diff_h[j] = HEIGHT - suitor_h[j];
diff_h[j] = WEIGHT - suitor_h[j];
}
//SORT THE DIFFERENCE FROM LEAST TO HIGHEST
// THEN PRINT THE NAMES FROM THE PERSON WITH the least difference to the one w/ highest
}
Example Input:
170 60
8
Allen 168 58
Wendell 166 60
Marlon 165 60
Brian 165 60
Christopher 172 57
Rene 175 65
Mark 169 75
Kelvin 170 58
Output:
Kelvin Mark Allen Christopher Wendell Brian Marlon Rene
Is there any algorithm, even a brute force one to get the answer?