Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* //1.Napisz program który za pomocą instrukcji for dla danych wartości zmieniających się w przedziale od 0 do 10. Oblicz wartość funkcji y=3x.
- static void Main(string[] args)
- {
- Console.Write("podaj x= ");
- int x = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i <= 10; i++)
- {
- int y = 3 * x;
- Console.WriteLine("{0}", y);
- Console.ReadKey(true);
- break;
- }
- }
- }
- }
- */
- //Zadeklaruj zmienną.Sprawdź czy wartość jest równa 1 lub 2. Użyj instrukcji switch.
- /* static void Main(string[] args)
- {
- Console.Write("podaj liczbe= ");
- int liczba = Convert.ToInt32(Console.ReadLine());
- switch (liczba)
- {
- case 1:
- Console.Write("jeden");
- break;
- case 2:
- Console.Write("dwa");
- break;
- default:
- Console.Write("nieznana wartość");
- break;
- }
- Console.ReadKey(true);
- }
- }
- }
- */
- //3.Napisz program wyświetlający tabliczkę mnożenia dla liczbod 1 do 100. z wykorzystaniem podwójnej pętli for.
- /* static void Main(string[] args)
- {
- for (int i = 1; i <= 10; i++)
- {
- for (int a = 1; a <= 10; a++)
- {
- int y = a * i;
- Console.Write("{0} ", y);
- }
- Console.WriteLine("");
- }
- Console.ReadKey(true);
- }
- }
- }
- */
- /* // 4.Napisz program który w zadeklarowanej tablicy 10x10 o nazwie macierz umieszcza na przekątnej liczbę 1 a poza nią 0. Program powinien obliczać sumę wyróżnionych elementów znajdujących się na jej przekątnej.
- static void Main(string[] args)
- {
- int[ , ] macierz = new int[10, 10];
- for (int x = 0; x < 10; x++)
- {
- for (int y = 0; y < 10; y++)
- {
- macierz[x, y] = 0;
- }
- }
- for(int i=0;i<10;i++)
- {
- macierz[i, i] = 1;
- }
- int licz = 0;
- for (int x = 0; x < 10; x++)
- {
- for (int y = 0; y < 10; y++)
- {
- if(macierz[x, y] == 1) { licz++; }
- }
- }
- Console.WriteLine("{0}\n", licz);
- for (int x = 0; x < 10; x++)
- {
- for (int y = 0; y < 10; y++)
- {
- Console.Write("{0} ", macierz[x , y]);
- }
- Console.WriteLine("");
- }
- Console.ReadKey(true);
- }
- }
- }
- */
- // 5. Napisz funkcję która policzy 6 wyrazów ciągu Fibonnaciego i wypisze jego sumę.
- static void Main(string[] args)
- {
- Console.Write("podaj n= ");
- int n = Convert.ToInt32(Console.ReadLine());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement