Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------
- // rikiavimo funkcoja
- private static void RikiuotiTeksta(string fv, string fk, char[] skyrikliai, int[] a)
- {
- string[] lines = File.ReadAllLines(fv, Encoding.GetEncoding(1257));
- foreach (string line in lines)
- {
- if (line.Length > 0)
- {
- RikiuotiEilute(line, skyrikliai, fk, a);
- }
- }
- foreach (string line in lines)
- {
- if (line.Length > 0)
- {
- SpauzdintiManoKnyga(line, fk, a, skyrikliai);
- }
- }
- }
- //--------------------------
- //rikiuti eilute funkcija
- private static void RikiuotiEilute(string line, char[] skyrikliai, string fk,int[] a)
- {
- string[] parts = line.Split(skyrikliai, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < parts.Length; i++)
- {
- if (parts[i].Length >= a[i])
- {
- a[i] = parts[i].Length;
- }
- }
- }
- //----------------------------
- //spauzidnti ManoKnyga
- private static void SpauzdintiManoKnyga(string line, string fk, int[] a, char[] skyrikliai)
- {
- using (StreamWriter far=new StreamWriter(fk,true))
- {
- string[] parts = line.Split(' ');
- for (int i = 0; i < parts.Length; i++)
- {
- if (i == 0)
- far.Write("{0,-1}", parts[0]);
- else
- {
- for (int j = 0; j < a[i - 1]+2-parts[i-1].Length; j++)
- {
- far.Write(" ");
- }
- far.Write("{0}", parts[i]);
- }
- }
- far.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement