Would you PLEASE read replies?
Would you PLEASE use [code][/code]-tags?
Would you PLEASE read the reader?
Here's "working" code I fixed only C syntax and indexing errors. The sort algorithm works, but only sorts the ID's. I guess programming will never be a hobby of yours?
Code:
#include<stdio.h>
#define NOCHMAL 'y'
void datain (int, int[10000][4]);
void dataout (int, int[10000][4]);
int
main (void)
{
int down, person[10000][4];
/*choose the size of table required */
printf ("Please enter the amount of the people required:\n\r");
scanf ("%d", &down);
printf ("Amount of people required: %d\n\r", down);
/*validate user input */
while ((down <= 0) || (down > 10000))
{
printf ("please re-enter the number of people required:\n\r");
scanf ("%d", &down);
}
/*Create table and input data */
datain (down, person);
/*print out the table unsorted */
dataout (down, person);
return 0;
}
void
datain (int numberofpeople, int person[10000][4])
{
/*load up person arrays */
int array1;
for (array1 = 0; array1 < numberofpeople; array1++)
{
printf ("\n\rPlease input the person identification: ");
scanf ("%d", &person[array1][0]);
printf ("Please input the person Wage: ");
scanf ("%d", &person[array1][1]);
printf ("Please input the person Sex(0 is male and 1 is female):");
scanf ("%d", &person[array1][2]);
/*validate user input */
while ((person[array1][2] < 0) || (person[array1][2] > 1))
{
printf ("please re-enter the sex data\n\r");
scanf ("%d", &person[array1][2]);
}
printf ("Please input the person Age: ");
scanf ("%d", &person[array1][3]);
/*validate user input */
while ((person[array1][3] < 16) || (person[array1][3] > 65))
{
printf ("please re-enter the age data\n\r");
scanf ("%d", &person[array1][3]);
}
}
}
void
dataout (int number, int person[10000][4])
{
int array;
char nochmal;
char sort;
int index, total;
printf (" \n\r The Unsorted Data:\n");
printf (" ---------------------\n\r");
printf ("Personnal ID Wage Sex Age\n\r");
for (array = 0; array < number; array++)
{
printf ("%8d%8d%8d%8d\n\r", person[array][0],
person[array][1], person[array][2], person[array][3]);
}
/*select form of display from user */
nochmal = NOCHMAL;
while (nochmal == NOCHMAL)
{
/*select display from user */
printf ("\n\rHow is the data to be sorted ?");
printf ("\n\rAscending by Person ID,type a");
printf ("\n\rAscending by Wage, type b");
printf ("\n\rAscending by Age, type c");
printf ("\n\rOnly females, type f");
printf ("\n\rOnly males, type m\n\r");
scanf (" %c", &sort);
/* Sort the data */
/*
if (sort == 'a')
if (sort == 'b')
if (sort == 'c')
if (sort == 'd')
if (sort == 'f')
if (sort == 'm');
*/
for (index = 0; index < number; index++)
for (array = 0; array < number - 1; array++)
if (person[array][0] > person[array + 1][0])
{
total = person[array][0];
person[array][0] = person[array + 1][0];
person[array + 1][0] = total;
}
for (array = 0; array < number; array++)
{
printf ("Personnel ID: %d\t", person[array][0]);
printf ("Wage: %d\t", person[array][1]);
printf ("Sex: %d\t", person[array][2]);
printf ("Age: %d\t\n", person[array][3]);
}
/*to resort the data */
printf ("Would you like to sort the data again Yes = y No = n\n");
scanf (" %c", &nochmal);
}
}
(you are "The Weakest Link"...) Goodbye!