Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication3
- {
- class Program
- {
- static void Main(string[] args)
- {
- // 1. Stwórz tablicę od 500 do 0.
- // 2. Stwórz tablicę, gdzie co 5-ty element ma wartość 1.
- // 3. Stwórz tablicę przyjmującą tylko wartości 1 oraz -1.
- // 4. Tablica wartości od 50 do 90, co drugą (50, 52, 54, etc...)
- // 5. Oblicz sumę tablicy z zad. 4.
- // 6. Oblicz sumę tablicy z zad. 2.
- // 7. Stwórz dwie tablice (Jedna ma wartości -1, -2,-3,-4,...,-1000) (Druga ma wartości 1,2,3,4,...,1000)
- // 8. To co w zad. 7 (Pierwsza przyjmuje wartości -2000 do -1001)
- // 9. Tablica o rozm. 1000 i wszędzie przyjmuje wartość 0 poza i, gdzie i = 2^n.
- //1
- Console.WriteLine("\n\nAd. 1\n");
- int size = 501;
- int[] tab1 = new int[size];
- int i = tab1.Length - 1;
- while(i >= 0)
- {
- tab1[i] = i;
- Console.Write($"{tab1[i]}, ");
- i--;
- }
- //2
- Console.WriteLine("\n\nAd. 2\n");
- int size2 = 10;
- int[] tab2 = new int[size2];
- for (int j = 0; j < tab2.Length; j++)
- {
- if ((j + 1) % 5 == 0)
- {
- tab2[j] = 1;
- }
- Console.Write($"{tab2[j]}, ");
- }
- //3
- Console.WriteLine("\n\nAd. 3\n");
- int size3 = 10;
- int[] tab3 = new int[size3];
- for (int k = 0; k < tab3.Length; k++)
- {
- if (k % 2 == 0)
- {
- tab3[k] = 1;
- }
- else
- tab3[k] = -1;
- Console.Write($"{tab3[k]}, ");
- }
- //4
- Console.WriteLine("\n\nAd. 4\n");
- int size4 = (91 - 48) / 2;
- int[] tab4 = new int[size4];
- int valueI = 50;
- int l = 0;
- for (; l < tab4.Length; l++)
- {
- tab4[l] = valueI;
- valueI = valueI + 2;
- Console.Write($"{tab4[l]}, ");
- }
- //5
- Console.WriteLine("\n\nAd. 5\n");
- int m = 0;
- int summary1 = 0;
- while (m < tab4.Length)
- {
- summary1 += tab4[m];
- m++;
- }
- Console.Write(summary1);
- //6
- Console.WriteLine("\n\nAd. 6\n");
- int n = 0;
- int summary2 = 0;
- while(n < tab2.Length)
- {
- summary2 += tab2[n];
- n++;
- }
- Console.Write(summary2);
- //7
- Console.WriteLine("\n\nAd. 7\n");
- int size7 = 1000;
- int[] tab7 = new int[size7];
- int[] tab7a = new int[size7];
- for (int o = 0; o < tab7.Length; o++)
- {
- tab7[o] = o + 1;
- Console.Write($"{tab7[o]}, ");
- }
- Console.WriteLine("\n");
- for (int p = 0; p < tab7a.Length; p++)
- {
- tab7a[p] = (p + 1) * (-1);
- Console.Write($"{tab7a[p]}, ");
- }
- //8
- Console.WriteLine("\n\nAd. 8\n");
- int size8 = 1000;
- int[] tab8 = new int[size8];
- int s = -2000;
- for (int r = 0; r < tab8.Length; r++)
- {
- tab8[r] = s;
- s++;
- Console.Write($"{tab8[r]}, ");
- }
- //9
- Console.WriteLine("\n\nAd. 9\n");
- int size9 = 1000;
- int[] tab9 = new int[size9];
- int u = 0;
- for (int t = 0; t < tab9.Length; t++)
- {
- if (t == Math.Pow(2,u))
- {
- tab9[t] = t;
- u++;
- }
- Console.Write(tab9[t]+" ");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement