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 Feladat2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] s = new int[100];
- generate(s);
- Console.WriteLine("A sorozat paratlan, ottel nem oszthato elemeinek szama: {0}",parotnem(s));
- elsoneg(s);
- lnab(s);
- }
- public static int[] generate(int[] t)
- {
- Random rand = new Random();
- for (int i = 0; i < t.Length; i++)
- {
- t[i] = rand.Next(-100, 100);
- }
- return t;
- }
- public static int parotnem(int[] t)
- {
- int count = 0;
- for (int i = 0; i < t.Length; i++)
- {
- if (t[i] % 2 == 1 && t[i] % 5 != 0)
- {
- count++;
- }
- }
- return count;
- }
- public static void elsoneg(int[] t)
- {
- int i = 0;
- while (t[i] > 0)
- {
- Console.WriteLine("{0}", t[i]);
- i++;
- }
- Console.WriteLine("Az elso negativ szam a {0} az {1} helyen.", t[i], i);
- }
- public static void lnab(int[] t)
- {
- int lna = 0;
- for (int i = 0; i < t.Length; i++)
- {
- if (t[lna] < t[i])
- {
- lna = i;
- }
- }
- Console.WriteLine("A legnagyobb abszolut erteku elem az {0}. helyen van.", lna);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement