Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
vigenere cypher
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { static int mod(int a,int b) { int abs = a < 0 ? -a:a; return a < 0? b - abs:(a > b? a - b:a); } public static void Main(string[] args) { int lc = 'a'; string key = Console.ReadLine().ToLower();//line 0 of input string txt = Console.ReadLine().ToLower();//line 1 of input /*{ string pr = txt; do{pr = Console.ReadLine();txt += '\n' + (pr != "" ? pr:"");}while (pr != ""); }*/ int ind = 0; foreach(char c in txt) { int ke = key[ind] - lc; int ch = mod(ke - (c - lc),26); if (char.IsLetter(c)){Console.Write((char)(ch + lc)); ind ++;}else{Console.Write(c);} ind = ind % key.Length; } } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
ASCII -> Braille ASCII
PYRAMIDPATTERN
Student Cables
Intuit // C# // listing_4.3 (StreamWriter // @"c:\Temp\output.txt")
function in event
Can a == true && a == false be true in C#?
Moon Gravity
Func Delegate
Intuit // C# // listing_4.4 (StreamReader // input.txt)
Crystals Plep
stackse - search stackoverflow differently
Please log in to post a comment.