|
|
| Author |
Message |
|
| h725 |
Posted: Tue Nov 29, 2011 6:09 pm |
|
|
|
Joined: 29 Nov 2011
Posts: 2
|
Hallo,
ich habe ein kleines Problem. Ich weiss leider nicht wo ich in meinem Programm ein NewLine einfügen kann.
Mein Programm macht folgendes. Es liest eine Datei, alle Wörter sollen mit Quicksort sortiert werden und dann in eine zweite Datei ausgegeben werden. Wenn ich das in eine Datei schreibe, sind alle Wörter miteinander verbunden. Vielleicht kann mir einer bei meinem Problem helfen.
Hier noch mein Code:
Code:
-module(readlines3).
-compile([export_all]).
%Aufgabe3 -> Datei einlesen, sortieren und wieder ausgeben.
sort(File1,File2) ->
{ok, Datei_Lesen} = file:read_file(File1),
%Schreibe in Liste die komplette Datei. Wandle die Datei in eine Liste um und trenne Die Wörter nach dem Leerzeichen.
Liste = string:tokens(erlang:binary_to_list(Datei_Lesen), " "),
%Sortiere die Liste mit Quicksort
Sortierte_Liste = quicksort(Liste),
%Schreiben der sortierten Liste in die zweite Datei.
{ok,Datei_Schreiben} = file:open(File2, write),
file:write(Datei_Schreiben, Sortierte_Liste),
file:close(Datei_Schreiben).
quicksort([])->[];
quicksort([X|XS])-> quicksort([Y||Y<-XS,Y<X])++[X]++quicksort([Y||Y<-XS,Y>X]). |
|
|
| Back to top |
|
| wantjersey |
Posted: Fri Aug 17, 2012 6:10 am |
|
|
|
User
Joined: 17 Aug 2012
Posts: 10
|
| You can find various websites over the internet where you can place an order for the kind of cheap soccer cheap nhl jerseys you want. Once you place an order, your jersey would be delivered to you within a few working days. However, before ordering, make sure that the website is genuine or not selling nhl hockey jerseys that ride high on quality. |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|