Autor |
Beitrag |
Boldar
Beiträge: 1555
Erhaltene Danke: 70
Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
|
Verfasst: Mo 30.11.09 16:20
Wer da noch durchblickt, darf stolz sein:
(da is noch alles drin, was ich sonst noch so ausprobiert hatte...)
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179:
| unit Unit_main;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
const LF = #13#10;
var table: array[0..99] of char;
type TForm28 = class(TForm) Memo1: TMemo; Button1: TButton; Memo2: TMemo; Memo3: TMemo; Button2: TButton; Button3: TButton; PaintBox1: TPaintBox; Memo4: TMemo; Button4: TButton; Memo5: TMemo; Button5: TButton; Button6: TButton; Panel1: TPanel; Memo6: TMemo; Button7: TButton; Memo7: TMemo; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button7Click(Sender: TObject); private public end;
var Form28: TForm28; f: TEXT;
implementation
{$R *.dfm}
procedure writelog (str: string); begin writeln (f,str); end;
procedure TForm28.Button1Click(Sender: TObject); var I: Integer; var chars : set of char; begin memo1.Text := stringreplace (memo1.Text, '-', ' ', [rfreplaceall]); chars := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ']; memo2.Clear; for I := 0 to length(memo1.Text) - 1 do begin if char(memo1.text[i]) in chars then begin memo2.Text := memo2.Text + memo1.Text[i]; writelog ('hinzugefügt: '+inttostr(i)); end else writelog ('passed: '+inttostr(i));
end;
end;
procedure TForm28.Button2Click(Sender: TObject); begin memo3.text := memo2.Text; memo3.Text := stringreplace (memo3.Text, ' ', LF, [rfreplaceall]); end;
procedure TForm28.Button3Click(Sender: TObject); var i: Integer; var arr: array [0..30] of byte; begin fillchar (arr, length(arr), $00); for i := 0 to memo3.lines.count - 1 do begin arr[length(memo3.lines[i])] := arr[length(memo3.lines[i])]+1; end; for I := length(arr)-1 downto 0 do begin if arr[i]<>0 then begin showmessage (inttostr(i)); break; end; end; for I := 0 to 30 do begin paintbox1.Canvas.MoveTo((2*i)+1, 1); paintbox1.Canvas.LineTo((2*i)+1, arr[i]); end; end;
procedure TForm28.Button4Click(Sender: TObject); begin memo4.Text := stringreplace (memo3.Text, ' ', '', [rfreplaceall]); memo4.Text := stringreplace (memo4.Text, #13, '', [rfreplaceall]); memo4.Text := stringreplace (memo4.Text, #10, '', [rfreplaceall]); end;
procedure TForm28.Button5Click(Sender: TObject); var s: string; var ch1, ch2: char; begin s := memo4.Text; memo5.Clear; repeat ch1 := s[1]; ch2 := s[2]; s:=stringreplace(s, ch1, '', []); s:=stringreplace(s, ch2, '', []); memo5.Lines.Add(ch1+ch2); until length(s)<2; end;
function decode (ch1, ch2: char):char; var b: byte; begin b := strtoint(ch1)*10+strtoint(ch2); result := table[b]; end; procedure TForm28.Button7Click(Sender: TObject); var s: string; var ch1, ch2: char; var chars : set of char; begin chars := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; s := memo1.text; memo6.clear; repeat ch1 := s[1]; ch2 := s[2]; if (ch1 in chars)and (ch2 in chars) then begin memo6.Text := memo6.Text + decode (ch1, ch2); application.ProcessMessages; s:=copy (s, 3, length(s)); end else begin memo6.text := memo6.text+ch1; s:=copy (s, 2, length(s)); end; until length(s)<5; end;
procedure TForm28.FormCreate(Sender: TObject); var I: Integer; begin assignfile (f, 'C:\Log_gw.txt'); rewrite (f); for I := 0 to memo7.lines.count - 1 do table[i]:=(memo7.lines[i])[1]; end;
procedure TForm28.FormDestroy(Sender: TObject); begin closefile (f); end;
end. |
|
|
jfheins
Beiträge: 918
Erhaltene Danke: 158
Win 10
VS 2013, VS2015
|
Verfasst: Mo 30.11.09 16:37
Dann poste ich meinen auch mal
Hat inzwischen auc ein q ^^ 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Linq;
namespace Test_1 { public partial class Form1 : Form { Dictionary<byte, char> table;
public Form1() { InitializeComponent();
table = new Dictionary<byte, char>();
table.Add(0, 'a'); table.Add(1, 'a'); table.Add(2, 'a'); table.Add(3, 'a'); table.Add(4, 'a'); table.Add(5, 'a'); table.Add(6, 'b'); table.Add(7, 'b'); table.Add(8, 'c'); table.Add(9, 'c'); table.Add(10, 'd'); table.Add(11, 'd'); table.Add(12, 'd'); table.Add(13, 'd'); table.Add(14, 'd'); table.Add(15, 'e'); table.Add(16, 'e'); table.Add(17, 'e'); table.Add(18, 'e'); table.Add(19, 'e'); table.Add(20, 'e'); table.Add(21, 'e'); table.Add(22, 'e'); table.Add(23, 'e'); table.Add(24, 'e'); table.Add(25, 'e'); table.Add(26, 'e'); table.Add(27, 'e'); table.Add(28, 'e'); table.Add(29, 'e'); table.Add(30, 'e'); table.Add(31, 'e'); table.Add(32, 'f'); table.Add(33, 'f'); table.Add(34, 'g'); table.Add(35, 'g'); table.Add(36, 'g'); table.Add(37, 'h'); table.Add(38, 'h'); table.Add(39, 'h'); table.Add(40, 'h'); table.Add(41, 'h'); table.Add(42, 'i'); table.Add(43, 'i'); table.Add(44, 'i'); table.Add(45, 'i'); table.Add(46, 'i'); table.Add(47, 'i'); table.Add(48, 'i'); table.Add(49, 'i'); table.Add(50, 'j'); table.Add(51, 'k'); table.Add(52, 'l'); table.Add(53, 'l'); table.Add(54, 'l'); table.Add(55, 'm'); table.Add(56, 'm'); table.Add(57, 'n'); table.Add(58, 'n'); table.Add(59, 'n'); table.Add(60, 'n'); table.Add(61, 'n'); table.Add(62, 'n'); table.Add(63, 'n'); table.Add(64, 'n'); table.Add(65, 'n'); table.Add(66, 'n'); table.Add(67, 'o'); table.Add(68, 'o'); table.Add(69, 'p'); table.Add(70, 'q'); table.Add(71, 'r'); table.Add(72, 'r'); table.Add(73, 'r'); table.Add(74, 'r'); table.Add(75, 'r'); table.Add(76, 'r'); table.Add(77, 'r'); table.Add(78, 's'); table.Add(79, 's'); table.Add(80, 's'); table.Add(81, 's'); table.Add(82, 's'); table.Add(83, 's'); table.Add(84, 's'); table.Add(85, 't'); table.Add(86, 't'); table.Add(87, 't'); table.Add(88, 't'); table.Add(89, 't'); table.Add(90, 't'); table.Add(91, 'u'); table.Add(92, 'u'); table.Add(93, 'u'); table.Add(94, 'u'); table.Add(95, 'v'); table.Add(96, 'w'); table.Add(97, 'x'); table.Add(98, 'y'); table.Add(99, 'z');
}
private void button1_Click(object sender, EventArgs e) {
string str = "";
int i = 0; while (i < textBox1.Text.Length) { if (char.IsDigit(textBox1.Text[i])) { var num = byte.Parse(string.Concat(textBox1.Text[i], textBox1.Text[i + 1])); if ((byte)table[num] > 0) { str += table[num]; } else { str += '_'; } i = i + 2; } else { str += textBox1.Text[i]; i++; } }
textBox2.Text = str; }
private void button3_Click(object sender, EventArgs e) { var rand = new Random();
string klar = textBox2.Text.ToLower(); klar = klar.Replace("ß", "ss"); klar = klar.Replace("ä", "ae"); klar = klar.Replace("ö", "oe"); klar = klar.Replace("ü", "ue"); string cipher = "";
foreach (var item in klar) { if (char.IsLetter(item)) {
var possible = new List<byte>(from a in table where a.Value == item select a.Key);
cipher += possible[rand.Next(possible.Count)].ToString("D2"); } else cipher += item; } textBox1.Text = cipher; } } } |
|
|
|