Last active
October 3, 2016 17:54
-
-
Save dz0/a239cd2125d7c2d48cf4abd6d9080948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication1_chatBot_dublis | |
| { | |
| class Program | |
| { | |
| static string ar_yra_tekste(string txt, string ko_ieskom) | |
| { | |
| if (txt.Contains(ko_ieskom)) | |
| { | |
| return "Yra \"" + ko_ieskom +"\""; | |
| } | |
| else return "Neradom, ko ieskojom "; | |
| } | |
| static string padubliuok(string txt) | |
| { | |
| return txt + " " + txt; // reaguoja i paduotus duomenis/parametrus/argumentus | |
| } | |
| static void statistika( string txt) | |
| { | |
| Console.WriteLine("Teksto ilgis: "+ txt.Length ); | |
| string[] zodziai = txt.Split(' '); | |
| Console.WriteLine("Zodziu kiekis: "+ zodziai.Length ); | |
| } | |
| static string sifruok( string txt, int k=1 ) | |
| // https://en.wikipedia.org/wiki/Caesar_cipher | |
| // k - per kiek vietu pastumti simboli ASCII lenteleje | |
| // http://www.asciitable.com/index/asciifull.gif | |
| { | |
| string rez = ""; | |
| foreach(char simb in txt) // su kiekvienu simboliu is teksto | |
| { | |
| int nr = (int)simb; // paverciame simboli i skaiciuka (jo numeri ASCII lentelej) | |
| // Kodavimo "burtai" | |
| // rez += (char)(nr + k); // pastumiam numeri, paverciam atgal i simboli, ir pridedam prie rezultato | |
| int naujas_nr = nr + k; // pastumiam numeri | |
| char naujas_simbolis = (char)naujas_nr; // paverciam atgal i simboli | |
| rez += naujas_simbolis; // ir pridedam prie rezultato | |
| Console.WriteLine(simb + " --> " + (char)(nr + k)); | |
| } | |
| return rez; | |
| } | |
| static void Main(string[] args) | |
| { | |
| string input; | |
| Console.WriteLine("Ka manai?"); | |
| // reagavimas i naudotojo teksta | |
| do | |
| { | |
| input = Console.ReadLine(); // vel laukiam ivedamo teksto | |
| statistika(input); | |
| Console.WriteLine( sifruok(input) ); | |
| Console.WriteLine( padubliuok(input) ); | |
| //Console.WriteLine( ar_yra_tekste(input, "?")); | |
| } while (input != "ate"); | |
| Console.WriteLine("Viso geriausio...!"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment