コード例 #1
0
ファイル: Program.cs プロジェクト: MuhamedAbdalla/RSA
            num exgcd(List <char> x, List <char> y)
            {
                num res = new num();

                if (BigInteger.CompareTo("0".ToList(), y) == 0)
                {
                    res.remA = "1".ToList();
                    res.remB = "0".ToList();
                    res.gcd  = x.ToList();
                    return(res);
                }
                if (equal(y, "2".ToList()))
                {
                    res = res + exgcd(y, longDivision(x, 2).Value);
                }
                else
                {
                    res = res + exgcd(y, module(x, y));
                }
                num res2 = new num();

                res2.remA = res.remB.ToList();
                res2.remB = Subtract(res.remA, Logmultiply(divide(x, y), res.remB));
                res2.gcd  = res.gcd;
                return(res2);
            }
コード例 #2
0
ファイル: Main.cs プロジェクト: Va11hal1a/sapper
        private void start_the_game()
        {
            Int32.TryParse(textBox1.Text, out wc); hc = wc;
            w    = ww / wc;
            h    = hw / hc;
            dots = new dot[wc, hc];
            Random rand = new Random(69);

            for (int x = 0; x < wc; x++)
            {
                for (int y = 0; y < hc; y++)
                {
                    int n = rand.Next(0, 100);
                    if (n < fullness)
                    {
                        dots[x, y] = new bomb();
                    }
                    else
                    {
                        dots[x, y] = new empty();
                    }
                }
            }
            for (int x = 0; x < wc; x++)
            {
                for (int y = 0; y < hc; y++)
                {
                    if (dots[x, y].tp != type.bomb)
                    {
                        int count = 0;
                        for (int x1 = -1; x1 <= 1; x1++)
                        {
                            for (int y1 = -1; y1 <= 1; y1++)
                            {
                                if (x + x1 < 0 || y + y1 < 0 || y + y1 >= hc || x + x1 >= wc)
                                {
                                    continue;
                                }
                                if (dots[x + x1, y + y1].tp == type.bomb)
                                {
                                    count++;
                                }
                            }
                        }
                        if (count == 0)
                        {
                            dots[x, y] = new empty();
                        }
                        else
                        {
                            dots[x, y] = new num(count);
                        }
                    }
                }
            }
            this.Controls.Clear();
            form = state.game;
            Invalidate();
        }
コード例 #3
0
        public IplImage skin_hsv(IplImage image)
        {
            int xi, x, y, p;
            IplImage img_hsv;
            img_hsv = cvlib.cvCreateImage(cvlib.cvGetSize( image), 8, 3);
            cvlib.cvCvtColor( image,  img_hsv, cvlib.CV_BGR2HSV);

            num[,] bmpdata;
            bmpdata = new num[image.height, image.width];

            byte[] dataIn = img_hsv.ImageData;

            for (y = 0; y < image.height; y++)
            {
                for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
                {
                    //column position
                    p = y * image.widthStep + xi;

                    //grab the pixel data
                    bmpdata[y, x].H = dataIn[p];
                    bmpdata[y, x].S = dataIn[p + 1];
                    bmpdata[y, x].V = dataIn[p + 2];
                }
            }

            for (y = 0; y < image.height; y++)
            {
                for (x = 0; x < image.width; x++)
                {
                    if (bmpdata[y, x].H <= 19 && bmpdata[y, x].S >= 48) //jika kondisi cocok maka jgn d hitamkan
                        bmpdata[y, x].H += 0;
                    else
                        bmpdata[y, x].H = bmpdata[y, x].S = bmpdata[y, x].V = 0;
                }
            }

            for (y = 0; y < image.height; y++)
            {
                for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
                {
                    //column position
                    p = y * image.widthStep + xi;

                    //grab the pixel data
                    dataIn[p] = bmpdata[y, x].H;
                    dataIn[p + 1] = bmpdata[y, x].S;
                    dataIn[p + 2] = bmpdata[y, x].V;
                }
            }

            img_hsv.ImageData = dataIn;

            IplImage res = cvlib.cvCreateImage(cvlib.cvGetSize( image), 8, 3);
            cvlib.cvCvtColor( img_hsv,  res, cvlib.CV_HSV2BGR);

            cvlib.cvReleaseImage( img_hsv);
            return res;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: MuhamedAbdalla/RSA
            static public num operator +(num val1, num val2)
            {
                num res = new num();

                res.remA = val2.remA.ToList();
                res.remB = val2.remB.ToList();
                res.gcd  = val2.gcd.ToList();
                return(res);
            }
コード例 #5
0
        static void Main(string[] args)
        {
            num numo = new num(1);

            numo.print();
            num nump = new num(2, 3);

            nump.print();
            Console.ReadLine();
        }
コード例 #6
0
ファイル: numTest.cs プロジェクト: baket432/maxshev
        public void SumTest()
        {
            string x = "А321УЕ76";

            bool expected = true;

            num  a      = new num();
            bool actual = a.qwe(x);

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: 1320068008/AchaoCalculator
        static void Main(string[] args)
        {
            int n;

            Console.WriteLine("请输入计算题总个数: ");
            n = int.Parse(Console.ReadLine());
            num n1 = new num(n);

            n1.create();
            Console.ReadKey();
        }
コード例 #8
0
        protected void writeGoto(StringWriter writer, num, map)
        {
            writer.write((string)num."=>array(");
            foreach (var trigger =>
                     destination  in
                     map)
            {
                writer.write(sprintf("" % s "=>%d", trigger, destination));
                writer.write(",");
            }

            writer.write(")");
        }
コード例 #9
0
        protected void writeState(StringWriter writer, num, state)
        {
            writer.write((string)num."=>array(");
            foreach (var trigger =>
                     action  in
                     state)
            {
                this.writeAction(writer, trigger, action);
                writer.write(",");
            }

            writer.write(")");
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Meghahr97/day4assignment
        static void Main(string[] args)
        {
            int number;

            Console.WriteLine("Enter the number");
            number = int.Parse(Console.ReadLine());
            ClassMethods c  = new ClassMethods();
            num          nm = c.printnumber;

            nm += c.printMoney;
            nm += c.printHeximal;
            nm(number);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: MuhamedAbdalla/RSA
            public void GetKey()
            {
                num         ret = new num();
                List <char> p   = "961748941".ToList();
                List <char> q   = new List <char>();

                q.Add('9');
                q.Add('8');
                q.Add('2');
                q.Add('4');
                q.Add('5');
                q.Add('1');
                q.Add('6');
                q.Add('5');
                q.Add('3');
                List <char> n = Logmultiply(p, q);

                p = Subtract(p, "1".ToList());
                q = Subtract(q, "1".ToList());
                List <char> phi = Logmultiply(p, q);
                List <char> e   = "2".ToList();

                while (less(e, phi))
                {
                    num val = exgcd(e.ToList(), phi.ToList());
                    if (equal(val.gcd, "1".ToList()))
                    {
                        break;
                    }
                    else
                    {
                        e = Add(e, "1".ToList());
                    }
                }
                List <char> d       = divide(Add("1".ToList(), Logmultiply("2".ToList(), phi)), e);
                List <char> message = "20".ToList();
                List <char> c       = modPower(message, e, n);
                List <char> m       = modPower(c, d, n);

                Console.Write("Public Key Is (e, n) --> (");
                for (int i = 0; i < e.Count; i++)
                {
                    Console.Write(e[i]);
                }
                Console.Write(", ");
                for (int i = 0; i < n.Count; i++)
                {
                    Console.Write(n[i]);
                }
                Console.WriteLine(")");
            }
コード例 #12
0
        static void Main(string [] args)
        {
            int number;

            Console.WriteLine("ENTER THE NUMBER");
            number = int.Parse(Console.ReadLine());
            numericformats n = new numericformats();

            num nm = n.printnumber;

            nm += n.printMoney;
            nm += n.printHexadecimal;
            nm(number);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: mirnaghayes/-
        static void Main(string[] args)
        {
            int result_1, result_2;

            int[] array = new int[8];
            array[0] = 10;
            array[1] = 7;
            array[2] = 6;
            array[3] = 5;
            array[4] = 8;
            array[5] = 3;
            array[6] = 2;
            array[7] = 1;
            for (int i = 0; i < 4; i++)
            {
                if (array[i] % 2 != 0)
                {
                    {
                        result_1 = (Math.Max(Math.Max(array[0], array[1]), Math.Max(array[2], array[3])));
                        Console.WriteLine(result_1);
                    }
                }
            }

            for (int N = 4; N < 8; N++)
            {
                if (array[N] % 2 == 0)
                {
                    {
                        result_2 = (Math.Max(Math.Max(array[4], array[5]), Math.Max(array[6], array[7])));
                        Console.WriteLine(result_2);
                    }
                }
            }
            num res = new num();

            {
                "odd";
                "even";
            }
            Console.WriteLine();
        }
コード例 #14
0
        static void Main(string[] args)
        {
            ConsoleWriteLine("Choose P for Pine, O for Oak or M for Mahogany to find a price for your table ");
            num Choice = Console.ReadLine();

            if (Choice == "P")
            {
                Console.Write("The price for Pine is $100 ");
            }
            else if (Choice == "O")
            {
                Console.Write("The price for Oak is $225 ");
            }
            else if (Choice == "M")
            {
                Console.Write("The price for Mahogany is $310 ");
            }

            Console.Write("$0 ");
        }
コード例 #15
0
ファイル: ts_digits.cs プロジェクト: 0xCM/arrows
 static void dd_match_check <T>(string digits, num <T> value)
     where T : unmanaged
 => Claim.eq(digits, value.ToDecimalDigits().Format());
コード例 #16
0
 public static void ReadStart(in SMemLib.ARNum num, in int Interval = 50) => SML?.ReadStart(num, Interval);
コード例 #17
0
        public IplImage skin_hsv(IplImage image)
        {
            int      xi, x, y, p;
            IplImage img_hsv;

            img_hsv = cxcore.CvCreateImage(cxcore.CvGetSize(ref image), 8, 3);
            cv.CvCvtColor(ref image, ref img_hsv, cvtypes.CV_BGR2HSV);

            num[,] bmpdata;
            bmpdata = new num[image.height, image.width];

            byte[] dataIn = img_hsv.ImageDataUChar;

            for (y = 0; y < image.height; y++)
            {
                for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
                {
                    //column position
                    p = y * image.widthStep + xi;

                    //ambil pixel data
                    bmpdata[y, x].H = dataIn[p];
                    bmpdata[y, x].S = dataIn[p + 1];
                    bmpdata[y, x].V = dataIn[p + 2];
                }
            }

            for (y = 0; y < image.height; y++)
            {
                for (x = 0; x < image.width; x++)
                {
                    if (bmpdata[y, x].H <= 19 && bmpdata[y, x].S >= 48) //jika kondisi cocok maka jgn d hitamkan
                    {
                        bmpdata[y, x].H += 0;
                    }
                    else
                    {
                        bmpdata[y, x].H = bmpdata[y, x].S = bmpdata[y, x].V = 0;
                    }
                }
            }

            for (y = 0; y < image.height; y++)
            {
                for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
                {
                    //column position
                    p = y * image.widthStep + xi;

                    //ambil pixel data
                    dataIn[p]     = bmpdata[y, x].H;
                    dataIn[p + 1] = bmpdata[y, x].S;
                    dataIn[p + 2] = bmpdata[y, x].V;
                }
            }

            img_hsv.ImageDataUChar = dataIn;

            IplImage res = cxcore.CvCreateImage(cxcore.CvGetSize(ref image), 8, 3);

            cv.CvCvtColor(ref img_hsv, ref res, cvtypes.CV_HSV2BGR);

            cxcore.CvReleaseImage(ref img_hsv);
            return(res);
        }
コード例 #18
0
 => PairwiseGrouping(num, den, level).Select(PowerRules).MultiplyAll().InnerSimplified.Replace(CollapseMultipleFractions),
コード例 #19
0
 /// <summary>
 /// Get the prime factors of a number. Starting with the lowest.
 /// </summary>
 /// <param name="num">The number to factorize.</param>
 /// <returns>Enumerable of prime factors, as pairs (factor, exponent)</returns>
 public static List <(long factor, int count)> GetPrimeFactors(long num) => GetPrimeFactors(num, NextPrime);
コード例 #20
0
ファイル: Class667.cs プロジェクト: newchild/Project-DayZero
 Class536 class = new Class536(num.ToString(), Class885.class547_0.string_4, Class885.class547_0.int_1, this.class536_1.enum115_0, Origins.TopRight, Enum114.const_0, vector, 0.95f, false, Color.get_Red(), true);
コード例 #21
0
 /// <summary>
 /// Get the prime factors of a number. Starting with the lowest.
 /// </summary>
 /// <param name="num">The number to factorize.</param>
 /// <returns>Enumerable of prime factors, as pairs (factor, exponent)</returns>
 public static List <(BigInteger factor, int count)> GetPrimeFactors(BigInteger num) => GetPrimeFactors(num, NextProbablePrime);
コード例 #22
0
ファイル: R1Frac.cs プロジェクト: Surfndez/qsharp-runtime
 var(num, denom, q1)   = _args;
コード例 #23
0
 else if (num >= 1e180) return pDD(num / 1e180) + " Qr";
コード例 #24
0
        static void Main(string[] args)
        {
            #region Wypisz liczby od 1 do 100
            //for(int i = 1; i < 100; i++)
            //{
            //    Console.WriteLine(i);
            //}
            //Console.ReadLine();
            #endregion

            #region Wypisz liczby parzyste od 2 do 50

            //var czyParzysta = true;

            //if(czyParzysta)
            //{
            //    for (int i = 2; i < 50; i++)
            //    {
            //        if (i % 2 == 0 && i % 4 == 0)
            //        {
            //            Console.WriteLine(i);
            //            czyParzysta = false;
            //        }

            //    }
            //}
            //Console.ReadLine();
            #endregion

            #region Wypisz liczby od 100 do 1

            //for(int i = 100; i>=1;i--)
            //{
            //    Console.WriteLine(i);
            //}
            #endregion

            #region Wypisz liczby podzielne przez 8 w zakresie 1 do 100

            //bool czyPodzielna = true;
            //if (czyPodzielna)
            //{
            //for(int i = 1; i < 100; i++)
            //    {
            //        if (i % 8 == 0)
            //        {
            //            Console.WriteLine(i);
            //            czyPodzielna = false;
            //        }

            //    }
            //    Console.ReadLine();
            //}
            #endregion

            #region Wypisz najwieksza liczb niepodzielną przez 2,3,5,7, ale mniejsza od 1000

            //for (int i = 1000; i >0; i--)
            //{
            //if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0)
            //{
            //    Console.WriteLine(i);
            //    i = 0; // przeciążenie for lub break;
            //}

            //}



            #endregion

            #region Sprawdź czy podana jako parametr liczba jest parzysta. Istnieje mozliwosc wpisywania wartości do sprawdzenia wielokrotnie

            //bool endLoop = true;
            //while (endLoop)
            //{
            //    Console.WriteLine(" Enter a number:");
            //    var userNum = Console.ReadLine();

            //    if (userNum=="q")
            //    {
            //        endLoop = false;
            //        continue;
            //    }
            //    int num2;
            //    var result = int.TryParse(userNum, out num2);
            //    if (num2 % 2 == 0)
            //    {
            //        Console.WriteLine($"{userNum} jest liczba parzysta");
            //    }
            //  else
            //    {
            //        Console.WriteLine($"{userNum} Nie jest liczba parzystą");
            //    }
            //    Console.ReadLine();



            //}

            #endregion

            #region sprawdź czy podana jako parametr liczba jest liczbą pierwszą (podzielna tylko przez 1 i przez samą siebie). Mozesz wprowadzic tylko jedna liczbe do sprawdzenia

            //Console.WriteLine("Enetr a number:");
            //var userNum = Console.ReadLine();
            //int checkingNum;
            //var result = int.TryParse(userNum, out checkingNum);

            //if (result)
            //{
            //    if (checkingNum % 2 == 0 && checkingNum % 3 == 0 && checkingNum % 5 == 0)
            //    {
            //        Console.WriteLine($"{checkingNum} nie jest liczba pierwsza");
            //    }
            //    else
            //    {
            //        Console.WriteLine("To jest liczba pierwsza");
            //    }

            //}
            //else
            //{
            //    Console.WriteLine("Błędna wartość");
            //}
            //Console.ReadLine();
            #endregion

            #region  sprawdź czy podana jako parametr liczba jest liczbą pierwszą (podzielna tylko przez 1 i przez samą siebie). Mozesz wprowadzic wiele liczb do sprawdzenia

            //bool czyPierwsza = true;
            //while (czyPierwsza)
            //{
            //    Console.WriteLine("Enter a number:");
            //    var userNum = Console.ReadLine();
            //    if (userNum == "q")
            //    {
            //        czyPierwsza = false;
            //        continue;
            //    }

            //    int checkingNum;
            //    var result = int.TryParse(userNum, out checkingNum);

            //    if (result)
            //    {
            //    if(checkingNum%2==0 && checkingNum%3==0 && checkingNum % 5 == 0)
            //        {
            //            Console.WriteLine($"{checkingNum} nie jest liczba pierwsza");

            //        }
            //    else
            //        {
            //            Console.WriteLine($"{checkingNum} jest liczba pierwsza");
            //        }

            //    }
            //    else
            //    {
            //        Console.WriteLine("Koniec");
            //        Console.ReadLine();
            //    }

            //}
            #endregion

            #region Sprawdz czy podany numer PESEL jest poprawny
            bool endLoop = true;

            while (endLoop)
            {
                Console.WriteLine("Enter your PESEL number");
                var userImput = Console.ReadLine();
                if (userImput == "q")  // wielokrotna mozliwosc wpisywania numeru PESEL
                {
                    endLoop = false;
                    continue;
                }
                string [] num = new num[11];

                int checkinNum = 9a + 7b + 3c + 1d + 9e + 7f + 3g + 1h + 9i + 7j;
                var result     = int.TryParse(userImput, out checkinNum);
            }

            #endregion
        }
コード例 #25
0
ファイル: ts_digits.cs プロジェクト: 0xCM/arrows
 static void bd_match_check <T>(string digits, num <T> value)
     where T : unmanaged
 => Claim.eq(digits, value.ToBinaryDigits().Format(true));