I was asked to write a program, based on parent-child cooperation, which uses a “parallel” merge sort to a sequence of 800 numbers from a text file.I have to read the sequence of 800 integers, which I store in an array, and then pass half of them to a child, and the other half to the second child of the parent class. I have to do this until only 100 numbers are left in each child. When I have reached this the numbers must be sorted, which I am doing using a bubble sort.Once these are sorted the must be …

Member Avatar
Member Avatar
+0 forum 7

Hello, Working on my final project for a Java Class and have become stumped on the final leg of the code. We are supposed to create a program to add a record, remove a record, display a record, and list all records. The records must be written to a file. I have all of it working except the file part. I am able to get the program to write my array, (Which is what I am using to store and manipulate the records during program running), but I am having trouble getting it to read in the contents Back into …

Member Avatar
Member Avatar
+0 forum 6

So I've finally fixed up the functionality of an address book I've been writing (not on to utilizing a GUI yet of course though.)However to save or reclaim the data from the last use of the address book I, obviously, need to write and reclaim it from a .txt file, I understand how to write and read, however I'm not sure how to write so when it is read I can make it back into a dictionary. Any ideas? here's how I'm writing so far. [CODE]for line in AB.keys(): line=line+'\n ' print(line,file=f) for line in AB.values(): for string in line: …

Member Avatar
Member Avatar
+0 forum 3

I was doing a projecteuler problem. I made a program that would find all the prime numbers under 1000000 and write them all in a file. Why is that if I use the file name as "primes.txt", the result is gibberish from beginning to end, but when I use "primes.dat", the result is what I want. Please explain. Thanks :D

Member Avatar
Member Avatar
+0 forum 9

I want to remove all lines in a text file that start with HPL_ I have acheived this and can print to screen, but when I try to write to a file, I just get the last line of the amended text printed in the new file. Any help please, thank you! [CODE] open(FILE,"<myfile.txt"); @LINES = <FILE>; close(FILE); open(FILE,">myfile.txt"); foreach $LINE (@LINES) { @array = split(/\:/,$LINE); my $file = "changed"; open OUTFILE, ">$file" or die "unable to open $file $!"; print OUTFILE $LINE unless ($array[0] eq "HPL_"); } close(FILE); close (OUTFILE); exit;[/CODE]

Member Avatar
Member Avatar
+0 forum 2

The End.