| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- // распакованная строка
- string u = "";
- //текущий символ
- char TekSymbol;
- int LenUnRepeat = 0;
- char SymbolForRepeat;
- if (textBox1.Text != "")
- {
- string s = textBox1.Text;
- for (int i = 0; i < s.Length; i++)
- {
- TekSymbol = s[i];
- //модификация алгоритма
- if (TekSymbol == '0')
- {
- LenUnRepeat =Int32.Parse(s[i + 1].ToString());
- for (int j = 0; j < LenUnRepeat; j++)
- {
- u = u + s[i + 2];
- i++;
- }
- i = i + 1;
- }
- else
- //классическиий RLE
- {
- LenUnRepeat = Int32.Parse(s[i].ToString());
- SymbolForRepeat = s[i+1];
- for (int j = 0; j < LenUnRepeat; j++)
- {
- u = u + SymbolForRepeat;
- }
- i = i + 1;
- }
- }
- }
- label1.Text = u;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- }
- }
- }
|