File:  [Research Unix] / researchv10no / cmd / cfront / libstring / test17.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#include "list.h"

extern "C" {
	int rand();
	void srand();
}

listdeclare(int)

int	bigger(int&, int&);

main()
{
	int_list	myList;
	const sz = 500;
	int	arr[sz];
	srand();
	for (int i=0; i<sz; i++) arr[i] = i;
	for (i=sz; i; ) {
		int j = rand() % i;
		myList.put(arr[j]);
		arr[j] = arr[--i];
	}
	myList.sort(bigger);
	cout << myList << "\n";
}

int
bigger(int& a, int& b)
{
	return a < b;
}

listimplement(int)
listoutimplement(int)
/*
	int	i;
	while (cin >> i)
		myList.put(i);

	const sz = 200;
	int	arr[sz];
	srand();
	for (int i=0; i<sz; i++) arr[i] = i;
	for (i=sz; i; ) {
		int j = rand() % i;
		myList.put(arr[j]);
		arr[j] = arr[--i];
	}

	for (int i=0; i<200; i++)
		myList.put(i);
*/

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.