Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Program
- {
- public class Program
- {
- // nezinau ar reikia pasikartojancius simbolius skaiciuot ar ne, bet speju, kad nereikia, tai padariau lista, i kuri dedami rasti simboliai
- public static int NumberOfSymbols(string line, string s)
- {
- int result = 0;
- List<char> foundSymbols = new List<char>();
- if (!String.IsNullOrEmpty(line) && !String.IsNullOrEmpty(s))
- {
- for(int i = 0; i < line.Length; i++)
- {
- if (!foundSymbols.Contains(line[i]) && s.Contains(line[i].ToString()))
- {
- result ++;
- foundSymbols.Add(line[i]);
- }
- }
- }
- return result;
- }
- // nesumaisyk return true ir return false vietomis
- public static bool MoreVowels(string line)
- {
- string vowelLetters = "aąeęėiįyouųū";
- string consonantLetters = "bcčdfghjklmnprsštvzž";
- int vowelCount = 0;
- int consonantCount = 0;
- for (int i = 0; i < line.Length; i++)
- {
- if (vowelLetters.Contains(line[i].ToString().ToLower()))
- {
- vowelCount ++;
- }
- if (consonantLetters.Contains(line[i].ToString().ToLower()))
- {
- consonantCount ++;
- }
- }
- if (consonantCount >= vowelCount )
- {
- return false;
- }
- return true;
- }
- public static string FindWord1InLine(string line, string punctuation)
- {
- string resultingWord = "";
- string[] words = line.Split(punctuation.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- string[] puncArray = line.Split(words, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < words.Length; i++)
- {
- if (MoreVowels(words[i]))
- {
- resultingWord = words[i];
- if (i < puncArray.Length)
- {
- resultingWord += puncArray[i];
- }
- break;
- }
- }
- return resultingWord;
- }
- public static string FindWord2InLine(string line, string punctuation)
- {
- string resultingWord = "";
- string[] words = line.Split(punctuation.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- string[] puncArray = line.Split(words, StringSplitOptions.RemoveEmptyEntries);
- int maxLength = 0;
- for (int i = 0; i < words.Length; i++)
- {
- if (MoreVowels(words[i]) && words[i].Length > maxLength)
- {
- maxLength = words[i].Length;
- resultingWord = words[i];
- if (i < puncArray.Length)
- {
- resultingWord += puncArray[i];
- }
- }
- }
- return resultingWord;
- }
- // su situ editu yra vienas flaw, kuri zinau, bet nera laiko sutvarkyt, kai baigsi parasyk, paaiskinsiu kas per klaida :D gal destytojai patys nesugalvos patikrinti tokio varianto, kuriuo neveiktu pilnai teisingai
- public static string EditLine(string line, string punctuation, string word)
- {
- string[] words = line.Split(punctuation.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- string[] puncArray = line.Split(words, StringSplitOptions.RemoveEmptyEntries);
- if (!String.IsNullOrEmpty(word))
- {
- string newLine = "";
- for (int i = 0; i < words.Length; i++)
- {
- if (i < puncArray.Length)
- {
- words[i] += puncArray[i];
- }
- if (String.Compare(word, words[i]) == 0)
- {
- newLine = word;
- newLine += line.Replace(newLine, "");
- break;
- }
- }
- return newLine;
- }
- return line;
- }
- public static void PerformTasksN(string fd, string fr)
- {
- string punctuation = null;
- string[] lines = null;
- // read 'punctuation' and 'lines' from file here...
- int movedWordsCount = 0;
- List<string> movedWords = new List<string>();
- foreach(string line in lines)
- {
- string word = FindWord1InLine(line, punctuation);
- string wordWithoutPunctuation = word.Split(punctuation.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- movedWords.Add(wordWithoutPunctuation[0]);
- string editedLine = EditLine(line, punctuation, word);
- // write 'editedLine' to file here...
- if (!String.IsNullOrEmpty(word))
- {
- movedWordsCount ++;
- }
- string word2 = FindWord2InLine(line, punctuation);
- string word2WithoutPunctuation = word2.Split(punctuation.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- movedWords.Add(word2WithoutPunctuation[0]);
- editedLine = EditLine(line, punctuation, word2);
- // write 'editedLine' to file here...
- if (!String.IsNullOrEmpty(word2))
- {
- movedWordsCount ++;
- }
- }
- foreach(string word in movedWords)
- {
- // write 'word' to file here...
- }
- // write 'movedWordsCount' to file here...
- }
- }
- }
Add Comment
Please, Sign In to add comment