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();
}
}
}