Visual studio programy

0

Podaj liczby a program pokaże liczby pierwsze

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Ile liczb chcesz sprawdzić? ");
string b = Console.ReadLine();
int max = Convert.ToInt32(b);

Console.WriteLine("Liczby pierwsze to: ");

for (int i = 2; i <= max; i++)
{
if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0)
{ 
Console.WriteLine(i);
}
if (i==2 ||i==3||i==5||i==7)
{
Console.WriteLine(i);
}
}
Console.ReadLine();
        }
    }
}

macierz

int a = 5;
            int b = 10;
            int[,] tab = new int[3, 3] { { 1, 2, 3 }, { 11, 12, 13 }, { 21, 22, 23 } };


            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    Console.WriteLine("x:" + x + "y: " + y + "tab= " + tab[x, y]);
                }
            } Console.ReadLine();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {


            int a = 5;
            int b = 10;

            if (a == 5 && b==10)
            {
                Console.WriteLine("ciamciaramciam");
            }
            

            string znaki;
            znaki = Console.ReadLine();

            if (znaki == "a" || znaki == "b") Console.WriteLine("znaki są a lub b");
            if (znaki == "c" || znaki == "d") Console.WriteLine("Znaki są c lub d");
            Console.ReadLine();
        }
    }
}
0

Ile piw wypiłeś?
Program dopisuje do liczby słowo Piw lub piwa w zależności od podanej liczby

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Ile wypiłeś? ");
            string a;
            a = Console.ReadLine();
            int i = Convert.ToInt32(a);

            if (i == 1) Console.WriteLine(i + " piwo");
            else if (i % 10 == 1 || i % 10 == 0) Console.WriteLine(i + " piw");
            else if (i > 10 && i < 20) Console.WriteLine(i + " piw");
            else if (i % 10 >= 2 && i % 10 <= 4) Console.WriteLine(i + " piwa");
            else if (i % 10 >= 5 && i % 10 <= 9) Console.WriteLine(i + " piw");
            Console.ReadLine();
        }
    }
}

tablica

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 1;
            int[] tab = new int[] { 1, 2, 3, 4, 5, 15, 116, 1777 }; /* 8 elementów*/



            for (int i = 0; i < tab.Length; i++)
            {

                Console.WriteLine(tab[i]);
            }

            Console.ReadLine();
        }
    }
}

cos z tablica

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication35
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 1;
            int[] tab = new int[] { 1, 2, 3, 4, 5, 15, 116, 1777 };

            Console.WriteLine(tab[5]);
            Array arrr = new Array[] { };

            Console.ReadLine();
        }
    }
}
0

Program, który rysuje # w różnych kształtach w zależności od ustawienia programu

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 1; i++)
            {
                Console.WriteLine("#####");
            }
            for (int i = 1; i < 5; i++)
            {
                Console.WriteLine("#   #");
            }
            for (int i = 4; i < 5; i++)
            {
                Console.WriteLine("#####");
            }

            Console.ReadLine();
        }
    }
}
0

Program, który wypisuje w odstępach znaczki podane w programie

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    if (x % 2 == 0 && y % 2 == 0)
                        Console.Write(" $ ");
                    if (x % 2 != 0 && y % 2 != 0)
                        Console.Write(" ? ");
                    if (x % 2 == 0 && y % 2 != 0)
                        Console.Write(" # ");
                    if (x % 2 != 0 && y % 2 == 0)
                        Console.Write(" 0 ");
                }

                Console.WriteLine(" ");
                Console.WriteLine(" ");
            }
            Console.ReadLine();
        }
    }
}

ukladanie slowa

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication40
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = 0;

            string[] znak = new string[5] { "d", "g", "p", "e", "a" };

            while (a < znak.Length)
            {

                znak[a] = Console.ReadLine();
                a++;

            }


            string x = "";

            for (int i = 0; i < znak.Length; i++)
            {
                x += znak[i];

            }
            Console.WriteLine(x);
            Console.ReadLine();
        }
    }
}
0

Ale że co?

0

co co? po prostu wstawiłem programy, które komuś bedą potrzebne..

0

A może tak byś się nauczył formatować kod na forum?

0

No szczegolnie "Ile piw" i rysowanie durnych szlaczkow moze sie komus przydac...

Co najwyzej ten z liczbami pierwszymi moglby sie komus przydac na prace domowa pod warunkiem ze bylby napisany poprawnie...

0

perelka :D

1 użytkowników online, w tym zalogowanych: 0, gości: 1