Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Feladat2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] s = new int[100];
  14.  
  15. generate(s);
  16. Console.WriteLine("A sorozat paratlan, ottel nem oszthato elemeinek szama: {0}",parotnem(s));
  17. elsoneg(s);
  18. lnab(s);
  19.  
  20.  
  21. }
  22.  
  23. public static int[] generate(int[] t)
  24. {
  25. Random rand = new Random();
  26. for (int i = 0; i < t.Length; i++)
  27. {
  28. t[i] = rand.Next(-100, 100);
  29. }
  30. return t;
  31. }
  32.  
  33. public static int parotnem(int[] t)
  34. {
  35. int count = 0;
  36. for (int i = 0; i < t.Length; i++)
  37. {
  38. if (t[i] % 2 == 1 && t[i] % 5 != 0)
  39. {
  40. count++;
  41. }
  42. }
  43. return count;
  44. }
  45. public static void elsoneg(int[] t)
  46. {
  47. int i = 0;
  48. while (t[i] > 0)
  49. {
  50. Console.WriteLine("{0}", t[i]);
  51. i++;
  52. }
  53. Console.WriteLine("Az elso negativ szam a {0} az {1} helyen.", t[i], i);
  54. }
  55. public static void lnab(int[] t)
  56. {
  57. int lna = 0;
  58. for (int i = 0; i < t.Length; i++)
  59. {
  60. if (t[lna] < t[i])
  61. {
  62. lna = i;
  63. }
  64. }
  65. Console.WriteLine("A legnagyobb abszolut erteku elem az {0}. helyen van.", lna);
  66. }
  67.  
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement