Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 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. using System.IO;
  7.  
  8. namespace eldontestetele
  9. {
  10. class Program
  11. {
  12. //-- Fagyott-e
  13. static double[] homersekletek;
  14.  
  15. static void Main(string[] args)
  16. {
  17. homersekletek = Adatok();
  18. if (FagyottE()) Console.WriteLine("Fagyott.");
  19. else Console.WriteLine("Nem fagyott.");
  20. ProgEnd();
  21. }
  22.  
  23. static bool FagyottE()
  24. {
  25. bool f = false;
  26. for (int i = 0; i < homersekletek.Length; i++)
  27. {
  28. if (homersekletek[i] < 0)
  29. {
  30. f = true;
  31. break;
  32. }
  33. }
  34. return f;
  35. }
  36.  
  37. static double[] Adatok()
  38. {
  39. string fajl = @"C:\Users\mikaczo.david\Downloads\szovegfajlok\homersekletek.csv";
  40. if (!File.Exists(fajl))
  41. {
  42. Console.WriteLine("A fájl a {0} helyen nem létezik.", fajl);
  43. ProgEnd();
  44. }
  45. int N = File.ReadAllLines(fajl).Length;//sorok száma
  46. double[] vs = new double[N];
  47. using (StreamReader sr = new StreamReader(fajl))
  48. {
  49. for (int i = 0; i < N; i++)
  50. {
  51. string[] sor = sr.ReadLine().Split(';');
  52. vs[i] = double.Parse(sor[1]);
  53. }
  54. sr.Close();
  55. }
  56. return vs;
  57. }
  58.  
  59. static void ProgEnd()
  60. {
  61. Console.ReadKey();
  62. Environment.Exit(0);
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement