int main(int argc, char** argv){
  
  if(argc != 3) {
    printf("Usage: list_gen [amount][any number]\nExample: ./list_gen 5 1229");
    return EXIT_FAILURE;
  }
  
  int amount_people= atoi(argv[1]);
  time_t startRand=atoi(argv[2]);
  srand(time(&startRand));
  
  person_t* people=(person_t*)malloc(amount_people*sizeof(person_t));
  person_t* people_sorted=(person_t*)malloc(amount_people*sizeof(person_t));
  int* count_sort_hist=(int*)malloc(MAX_AGE*sizeof(int));
  int* tmp_hist=(int*)malloc(MAX_AGE*sizeof(int));
  
  generate_list(people, amount_people);
  
  printPeople(people,amount_people);
  
  /*sort*/
  printf("\n----------------------------\n");
  
  calcHistogram(people, count_sort_hist,amount_people);

  prefixSum(tmp_hist, count_sort_hist);
  
  countSortLastStage(people, people_sorted, tmp_hist, amount_people);
  
  printPeople(people_sorted,amount_people); 
  
  //finalization
  free(people);
  free(people_sorted);
  free(count_sort_hist);
  free(tmp_hist);
  
  return EXIT_SUCCESS; 
}
示例#2
0
int main()
{
	int choice;

	while (1){
		choice = showList();

		switch (choice){
		case 1:
			system("cls");
			printPeople();
		}

	}


}