Voteck Posted December 13, 2007 Report Share Posted December 13, 2007 Mam maly problem mianowicie mam do napisania 3 programy ale nie wiem jak. oto one: 1. Napisz program, który odwróci kolejność wyrazów w zdaniu. 2. Napisz program, który policzy ilość wystąpień kazdej z liter w zdaniu. 3. Napisz program, który pozwoli znależć wszystkie wystąpienia danego ciągu w innym ciągu. Pierwszy program robilem ale zobaczylem ze nie chodzi o zamiane liter lecz wyrazow... pomocy !!!! Link to comment Share on other sites More sharing options...
Force Posted December 13, 2007 Report Share Posted December 13, 2007 W czym problem? wczytujesz sobie po kolei znaki, patrzysz o spacja, no to do dodatkowej zmiennej Res dodajesz z przodu słowo i spację Res := slow+' '+Res; Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
Voteck Posted December 13, 2007 Author Report Share Posted December 13, 2007 W czym problem? wczytujesz sobie po kolei znaki, patrzysz o spacja, no to do dodatkowej zmiennej Res dodajesz z przodu słowo i spację Res := slow+' '+Res; A moglbys mi to napisac od begin ..... end ???? PLZ! Link to comment Share on other sites More sharing options...
Force Posted December 13, 2007 Report Share Posted December 13, 2007 W psedudo kodzie:P od begina do enda robi Toster za 100 złotych, a Filuu za 50 function Revers(s : string):string; begin // Zrob sam sekcje var temp := '' Res := '' petla od 1 do długość s rób jeśli s to znak to dodaj z tyłu tempa jeśli nie to Res:= temp+ ' '+Res; temp := ''; Result := Res; end; Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
Voteck Posted December 13, 2007 Author Report Share Posted December 13, 2007 W psedudo kodzie:P od begina do enda robi Toster za 100 złotych, a Filuu za 50 function Revers(s : string):string; begin // Zrob sam sekcje var temp := '' Res := '' petla od 1 do długość s rób jeśli s to znak to dodaj z tyłu tempa jeśli nie to Res:= temp+ ' '+Res; temp := ''; Result := Res; end; Ekhm ?? Dodaj tepa z tyłu ?? Link to comment Share on other sites More sharing options...
Voteck Posted December 13, 2007 Author Report Share Posted December 13, 2007 Jak widac nie polapie sie po tobie Mozesz napisac mi program caly ?? bylbym bardzo wdzieczny pozatym kupie ci ten toster:P Link to comment Share on other sites More sharing options...
Toster Posted December 13, 2007 Report Share Posted December 13, 2007 raczej Tego Tostera.... Always Dark<br /> Link to comment Share on other sites More sharing options...
kompustelnik Posted December 13, 2007 Report Share Posted December 13, 2007 Heh. Za darmo? Może Brainer się skusi... sam nie wiem. Takie prośby są chyba z deka nie na miejscu. Pozdrawiam! Pisze programy na zlecenia. Tanio! Delphi, Pascal. Kontakt: - (gg) 736483 - (email) kondor20@op.pl light92@o2.pl - Strona domowa Wszystko do uzgodnienia. Link to comment Share on other sites More sharing options...
Brainer Posted December 14, 2007 Report Share Posted December 14, 2007 Tutaj jest cały kodzik napisany w Delphi, ale wystarczy usunąć przełącznik kompilacji i powinien odpalić się w FPC. To rozwiązanie zadania pierwszego: CODEprogram Project1; {$APPTYPE CONSOLE} { .: GetSpaceText :. } function GetSpaceText(Src: String; Index: Integer; Delim_Char: Char): String; var I, J, Count: Integer; S: String; begin Result := ''; S := Src; I := 0; Count := 1; while (I begin J := Pos(Delim_Char, S); if (J = 0) then break; Delete(S, 1, J); Inc(I); end; for I := 1 to Length(Src) do if (Src = Delim_Char) then Inc(Count); if (Index > Count) then exit; J := Pos(Delim_Char, S); if (J = 0) then begin J := Length(S); Result := Copy(S, 1, J); end else Result := Copy(S, 1, J); end; function ReverseString(const S: String): String; var M, gF: String; I: Integer; begin gF := S + ' '; M := ''; for I := Length(gF) downto 1 do M := M + GetSpaceText(gF, I, ' '); Result := M; end; var S: String; begin writeln('Podaj zdanie do odwrocenia'); readln(S); S := ReverseString(S); writeln('Zdanie po odwroceniu: ', S); readln; end. Mam nadzieję, że pomogłem. .: Brainer :. patrick.nusbaum@gmail.com Link to comment Share on other sites More sharing options...
Force Posted December 14, 2007 Report Share Posted December 14, 2007 W Pacalu, nie Delphi Toster nie przejmuj się nie miałem na myśli agd:P Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
Brainer Posted December 14, 2007 Report Share Posted December 14, 2007 W Pacalu, nie Delphi To raczej zadziała w FPC. .: Brainer :. patrick.nusbaum@gmail.com Link to comment Share on other sites More sharing options...
Nvm Posted December 14, 2007 Report Share Posted December 14, 2007 @OT pozatym kupie ci ten toster:P :lol: :lol: - wybaczcie, że zachowuję się jak dziecko ale po prostu po przeczytaniu tej wiadomości nie potrafię się opanować @Topic Przecież pseudo kod Force'a jest dość jasny... Link to comment Share on other sites More sharing options...
Voteck Posted December 14, 2007 Author Report Share Posted December 14, 2007 heh dzieki za wszystko i sorry toster Mam jeszcze jedno pytanie.. mianowicie jak policzyc ilosc jakiegos znaku ktory wsytepuje z zdaniu ?? Link to comment Share on other sites More sharing options...
5corpio Posted December 14, 2007 Report Share Posted December 14, 2007 W pętli przejść przez wszystkie znaki i zwykłym if-em inkrementować wartość jakiegoś licznika ? Ot taka mini-strona moja po godzinach http://www.wnetrzekuchni.pl Link to comment Share on other sites More sharing options...
Force Posted December 14, 2007 Report Share Posted December 14, 2007 To chyba jest książkowy przykład, że ma się stringa i tablice, idzie po stringu, a w tablicy pod indeksem odpowiadającym kodowi znaku zwiększa się liczbę Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
kompustelnik Posted December 14, 2007 Report Share Posted December 14, 2007 For i:= 1 to Length(Tekst) do if Tekst[i] = 'a' then Inc(iloscA); Pozdrawiam! Pisze programy na zlecenia. Tanio! Delphi, Pascal. Kontakt: - (gg) 736483 - (email) kondor20@op.pl light92@o2.pl - Strona domowa Wszystko do uzgodnienia. Link to comment Share on other sites More sharing options...
Brainer Posted December 14, 2007 Report Share Posted December 14, 2007 For i:= 1 to Length(Tekst) do if Tekst[i] = 'a' then Inc(iloscA); Pozdrawiam! Twój pomysł jest nie za dobry. Bo w takim razie do każdej z liter musiałbyś mieć osobną zmienną (czyli ok. 32 zmienne - nie wiem ile jest liter! ). Najlepsze rozwiązanie zasugerował Force - trzeba stworzyć tablicę i w niej trzymać ilość znaków. .: Brainer :. patrick.nusbaum@gmail.com Link to comment Share on other sites More sharing options...
kompustelnik Posted December 14, 2007 Report Share Posted December 14, 2007 A no racja Nie czytałem tego co wyżej Chciał to ma xD. Niech wybiera Pozdrawiam! Pisze programy na zlecenia. Tanio! Delphi, Pascal. Kontakt: - (gg) 736483 - (email) kondor20@op.pl light92@o2.pl - Strona domowa Wszystko do uzgodnienia. Link to comment Share on other sites More sharing options...
Force Posted December 14, 2007 Report Share Posted December 14, 2007 3. Napisz program, który pozwoli znależć wszystkie wystąpienia danegociągu w innym ciągu. to mi się podoba, poszukaj o KMP w internecie, liniowy algorytm wyszukiwania wzorca w innym tekście O(n+m) Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.