예제 #1
0
    static void Main()
    {
        IntStream         strumNaturalny           = new IntStream();
        PrimeStream       strumPierwszych          = new PrimeStream();
        RandomStream      strumRandomowych         = new RandomStream();
        RandomWorldStream strumRandomowychStringow = new RandomWorldStream();

        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Reset strumienia.\n");
        strumNaturalny.reset();
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        if (strumNaturalny.eos() == false)
        {
            Console.Write("\tStan eos: falsz.\n");
        }
        else
        {
            Console.Write("\tStan eos: prawda.\n");
        }
        Console.Write("Kolejna liczba pierwsza: {0} \n", strumPierwszych.next());
        Console.Write("Kolejna liczba pierwsza: {0} \n", strumPierwszych.next());
        Console.Write("Kolejna liczba pierwsza: {0} \n", strumPierwszych.next());
        Console.Write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
        Console.WriteLine("Kolejna liczba losowa: {0} ", strumRandomowych.next());
        Console.WriteLine("Kolejna liczba losowa: {0}", strumRandomowych.next());
        Console.WriteLine("Kolejna liczba losowa: {0} ", strumRandomowych.next());
        Console.Write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
        Console.Write("Kolejny losowy string: {0}\n", strumRandomowychStringow.nextL());
        Console.Write("Kolejny losowy string: {0}\n", strumRandomowychStringow.nextL());
        Console.Write("Kolejny losowy string: {0}\n", strumRandomowychStringow.nextL());
    }
예제 #2
0
    public static void Main(string[] args)
    {
        IntStream test = new IntStream();

        Console.WriteLine("{0}", test.x);
        Console.WriteLine("{0}", test.next());
        Console.WriteLine("{0}", test.next());
        test.x = int.MaxValue;
        Console.WriteLine("{0}", test.eos());
        RandomStream tescik = new RandomStream();

        Console.WriteLine(tescik.x);
        tescik.reset();
        Console.WriteLine(tescik.x);
        Console.WriteLine(tescik.next());
        Console.WriteLine(tescik.eos());
        PrimeStream tescik2 = new PrimeStream();

        for (int i = 0; i < 5; i++)
        {
            Console.WriteLine(tescik2.next());
        }

        RandomWordStream a = new RandomWordStream();

        for (int i = 0; i < 20; i++)
        {
            Console.WriteLine(a.next());
        }
    }
예제 #3
0
        static void Main()
        {
            IntStream a = new IntStream();

            System.Console.WriteLine(a.next());
            System.Console.WriteLine(a.next());
            System.Console.WriteLine();

            a.reset();
            System.Console.WriteLine(a.next());
            System.Console.WriteLine(a.next());
            System.Console.WriteLine();

            Primestream p = new Primestream();

            System.Console.WriteLine(p.next());
            System.Console.WriteLine(p.next());
            System.Console.WriteLine(p.next());
            System.Console.WriteLine(p.next());
            System.Console.WriteLine();

            RandomStream r = new RandomStream();

            System.Console.WriteLine(r.next());
            System.Console.WriteLine(r.next());
            System.Console.WriteLine(r.next());
            System.Console.WriteLine();

            RandomWordStream rs = new RandomWordStream();

            System.Console.WriteLine(rs.next());
            System.Console.WriteLine(rs.next());
            System.Console.WriteLine(rs.next());
            System.Console.Read();
        }
예제 #4
0
파일: zad1.cs 프로젝트: rafpacut/ii
    public static void Main()
    {
        System.Console.WriteLine("IntStream");
        //IntStream
        IntStream iss = new IntStream();

        writeout(iss.next());
        writeout(iss.next());
        System.Console.WriteLine(iss.eos());
        iss.reset();
        System.Console.WriteLine(iss.eos());
        writeout(iss.next());

        while (!iss.eos())
        {
            iss.next();
        }
        System.Console.WriteLine("PrimeStream");


        //PrimeStream
        PrimeStream ps = new PrimeStream();

        for (int i = 0; i < 12; i++)
        {
            writeout(ps.next());
        }
        ps.reset();
        for (int i = 0; i < 12; i++)
        {
            writeout(ps.next());
        }
        System.Console.WriteLine("RandomStream");

        //RandomStream
        RandomStream rst = new RandomStream();

        writeout(rst.next());
        writeout(rst.next());
        writeout(rst.next());
        writeout(rst.next());

        System.Console.WriteLine("RandomWordStream");

        //RandomWordStream

        RandomWordStream rws = new RandomWordStream();
        RandomStream     rs1 = new RandomStream();
        PrimeStream      ps1 = new PrimeStream();

        for (int i = 0; i < 12; i++)
        {
            int prime = ps1.next();
            System.Console.WriteLine(rws.next(prime, rs1));
        }
    }
예제 #5
0
    static void Main()
    {
        int              i;
        PrimeStream      ps    = new PrimeStream();
        IntStream        ins   = new IntStream();
        RandomStream     rnd   = new RandomStream();
        RandomWordStream rndws = new RandomWordStream();

        Console.WriteLine(rnd.next());
        Console.WriteLine(rnd.next());
        Console.WriteLine(rnd.next());
        Console.WriteLine(ins.next());
        Console.WriteLine(ps.next());
        Console.WriteLine(ps.next());
        Console.WriteLine(ps.next());

        Console.WriteLine(rndws.next());
        Console.WriteLine(rndws.next());
        Console.WriteLine(rndws.next());

        rnd.reset();
        ins.reset();
        ins.next();
        for (i = 0; i < 10; i++)
        {
            Console.WriteLine("{0} losowa liczba: {1}", ins.next(), rnd.next());
        }

        rndws.reset();
        ps.reset();
        for (i = 0; i < 15; i++)
        {
            Console.WriteLine("slowo o dl = {0}: {1}", ps.next(), rndws.next());
        }
        ps.reset();
        for (i = 0; i < 30; i++)
        {
            Console.WriteLine("{0} liczba pierwsza = {1}", i + 1, ps.next());
        }
        ins.reset();
        int p = 0;

        while (!ins.eos())
        {
            p = ins.next();
        }
        Console.WriteLine("najwieksza liczba typu int = {0}", p);
    }
    public static void Main()
    {
        IntStream        stream = new IntStream();
        PrimeStream      prime  = new PrimeStream();
        RandomStream     rand   = new RandomStream();
        RandomWordStream word   = new RandomWordStream();

        Console.WriteLine("Next z klasy IntStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(stream.next());
        }
        Console.WriteLine("Next z klasy PrimeStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(prime.next());
        }

        Console.WriteLine("Next z klasy RandomStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(rand.next());
        }

        Console.WriteLine("Next z klasy RandomWordStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(word.next());
        }
    }
예제 #7
0
 public virtual int element(int i)
 {
     while (this.size() < i)
     {
         pulcheria.Add(eudoksja.next());
     }
     return(pulcheria[i - 1]);
 }
예제 #8
0
    public static void Main(string[] args)
    {
        IntStream intStream;

        intStream = new IntStream();

        Console.WriteLine("\nTesting IntStream: \n");

        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(intStream.next());
        }

        Console.WriteLine("\nTesting PrimeStream: \n");
        PrimeStream primeStream;

        primeStream = new PrimeStream();

        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(primeStream.next());
        }

        Console.WriteLine("\nTesting RandomStream: \n");
        RandomStream randomStream;

        randomStream = new RandomStream();

        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(randomStream.next());
        }

        primeStream.reset();
        Console.WriteLine("\nTesting RandomWordStream: \n");
        RandomWordStream randomWordStream;

        randomWordStream = new RandomWordStream(randomStream, primeStream);

        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(randomWordStream.next());
        }
    }
예제 #9
0
    static void Main()
    {
        int stan = 1;

        System.Console.WriteLine("Wybierz co chcesz zrobic:");
        System.Console.WriteLine("1.Kolejna liczba naturalna");
        System.Console.WriteLine("2.Wlacz/Wylacz strumien");
        System.Console.WriteLine("3.Sprawdz stan strumienia");
        System.Console.WriteLine("4.Reset");
        System.Console.WriteLine("5.Liczba losowa");
        System.Console.WriteLine("6.Kolejne liczby pierwsze");
        System.Console.WriteLine("7.Ciagi znakow o dlugosci liczb pierwszych");
        System.Console.WriteLine("8.Wyjscie");
        IntStream   instance        = new IntStream();
        PrimeStream prime           = new PrimeStream();
        PrimeStream primeForStrings = new PrimeStream();

        while (stan == 1)
        {
            string wybor = System.Console.ReadLine();
            switch (wybor)
            {
            case "1":
            {
                int liczba = instance.next();
                if (liczba == -1)
                {
                    System.Console.WriteLine("Strumien zamkniety");
                }
                else
                {
                    System.Console.WriteLine("Liczba naturalna: " + liczba);
                }
                break;
            }

            case "2":
            {
                bool eos = instance.endofstream;
                if (eos == true)
                {
                    instance.endofstream = false;
                }
                else
                {
                    instance.endofstream = true;
                }
                break;
            }

            case "3":
            {
                System.Console.WriteLine("Stan strumienia : " + instance.eos());
                break;
            }

            case "4":
            {
                instance = new IntStream();
                System.Console.WriteLine("Ustawienia zresetowane");
                break;
            }

            case "5":
            {
                RandomStream random = new RandomStream();
                if (instance.endofstream == false)
                {
                    System.Console.WriteLine("Liczba losowa:" + random.next());
                }
                else
                {
                    System.Console.WriteLine("Strumien zamkniety");
                }
                break;
            }

            case "6":
            {
                int wynik = prime.next();
                if (wynik == -1)
                {
                    instance.endofstream = true;
                    System.Console.WriteLine("Strumien zamkniety");
                }
                else
                {
                    System.Console.WriteLine("Kolejna Liczba Pierwsza " + wynik);
                }
                break;
            }

            case "7":
            {
                RandomWordStream ciag       = new RandomWordStream();
                string           rnd_string = ciag.next();
                System.Console.WriteLine("Losowy ciag znakow: " + rnd_string);
                break;
            }

            case "8":
            {
                stan = 0;
                break;
            }

            default:
            {
                System.Console.WriteLine("Bledny wybor");
                break;
            }
            }
        }
    }