Witam.
Mam takie zadanie: Załóżmy że mamy ciąg bitów: 01010101110, który znajduje się w pliku. Muszę napisać algorytm który przejdzie przez wszystkie podłańcuchy i je wyświetli. Niestety trochę już nad tym siędzę i nie wiem jak to napisać. Oto mój kod:
string substring = "";
string filename = "dane.txt";
using (StreamReader sr = new StreamReader(filename))
{
string bitstream = sr.ReadLine();
Console.WriteLine(bitstream + "\n");
for (int i = 0; i < bitstream.Length - 1; i++)
{
for (int d = bitstream.Length - 1; d >= 0; d--)
{
for (int j = i; j < d; j++)
{
substring += bitstream[j];
}
Console.WriteLine(substring);
}
}
}
Proszę o pomoc.