English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

this question is a program which should also be written in Java code.

2007-02-01 06:19:21 · 1 answers · asked by guitar 2 in Computers & Internet Programming & Design

1 answers

You don't really need an 'algorithm' per se, this is fairly straight-forward.

So do you want to read the numbers out of the file and reverse them, or put them into the file, read them back out and reverse them?

For the former case, here's what you'd do, in pseudo-java:

/**********/
File f = new File("nums.txt"); //open file
string contents = f.ReadToEnd(); //read file
f.Close(); //close file handle

//reverse the string from the file
string reversed = contents.Reverse(); //there should be some kind of equivalent member of the string object (if not, turn it into an array and sort it that way)

Console.WriteLine("here's the reversed string: " + reversed);
/**********/

If this doesn't help, check out the Google code base.

2007-02-01 07:26:27 · answer #1 · answered by fixedinseattle 4 · 0 0

fedest.com, questions and answers