Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Z_Boxen
- {
- class ZBoxen
- {
- public struct s_ZBoxen
- {
- public int Index;
- public char String;
- public int ZBoxCount;
- }
- const char DELIMITER = '$';
- s_ZBoxen[] ZBoxenArray;
- public s_ZBoxen[] GetZBoxenArray()
- { return this.ZBoxenArray; }
- public ZBoxen(string inputString) : this(inputString,string.Empty)
- { }
- public ZBoxen(string inputString, string inputPattern)
- {
- string tempString;
- if (string.IsNullOrEmpty(inputPattern))
- {
- tempString = inputString;
- }
- else
- {
- tempString = inputPattern;
- tempString += DELIMITER;
- tempString += inputString;
- }
- ZBoxenArray = new s_ZBoxen[tempString.Length];
- for (int i = 0; i < ZBoxenArray.Length; i++)
- {
- ZBoxenArray[i].Index = i;
- ZBoxenArray[i].String = tempString[i];
- ZBoxenArray[i].ZBoxCount = 0;
- }
- ZBoxenArray[0].ZBoxCount = -1;
- this.BerechneZBoxen();
- }
- private void BerechneZBoxen()
- {
- for(int i = 1; i < ZBoxenArray.Length; i++)
- {
- int tempCount = 0;
- for (int j = 0; j < ZBoxenArray.Length; j++)
- {
- if (i + j >= ZBoxenArray.Length)
- { ZBoxenArray[i].ZBoxCount = tempCount; break; }
- if (ZBoxenArray[i+j].String == ZBoxenArray[j].String)
- {
- ++tempCount;
- continue;
- }
- else
- {
- ZBoxenArray[i].ZBoxCount = tempCount; break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement