Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
UF pc
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Random rnd = new Random(); var number = rnd.Next(0, 9999); var start = DateTime.Now.AddYears(-25); int range = (DateTime.Now.AddYears(-15) - start).Days; var date = start.AddDays(rnd.Next(range)).ToString("yyMMdd"); while(!ModulusCheck(date+number.ToString("0000"))){ number = rnd.Next(0, 9999); } Console.WriteLine(date+"-"+number.ToString("0000")); } private static bool ModulusCheck(string nr) { decimal n; decimal checkSum = 0; decimal checkNum; var pnumArr = nr.ToCharArray(); if (nr.Length == 12) { for (var i = 2; i < 11; i++) { checkNum = 0; n = (decimal)pnumArr[i] - 48; if (i % 2 == 0) { checkNum += n * 2; } else { checkNum += n; } if (checkNum >= 10) { checkSum += 1 + (checkNum - 10); } else { checkSum += checkNum; } } } else { for (var i = 0; i < pnumArr.Count() - 1; i++) { checkNum = 0; n = (decimal)pnumArr[i] - 48; if (i % 2 == 0) { checkNum += n * 2; } else { checkNum += n; } if (checkNum >= 10) { checkSum += 1 + (checkNum - 10); } else { checkSum += checkNum; } } } var checkSum2 = checkSum.ToString(); var entalet = Convert.ToDecimal(checkSum2.Substring(checkSum2.Length - 1, 1)); if (entalet == 0) { entalet = 10; } if (10 - entalet == ((decimal)pnumArr[pnumArr.Count() - 1] - 48)) { return true; } return false; } } }
run
|
edit
|
history
|
help
0
clientdata.cs
pared 1
d
EX8 For_Loop & While_loop
cup tournament prediction
Typing Words
Клас cstatic
axasxasxasaxsd
PYRAMIDPATTERN
XmlException in XmlSerializer.Deserialize when XML has \0