Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace _11._18
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. StreamReader sr = new StreamReader("szoveg.txt");
  15. string szo;
  16. List<string> szavak = new List<string>();
  17.  
  18. Console.WriteLine("1. feladat ");
  19. Console.WriteLine("Kérlek írj be egy szót! ");
  20. szo = Console.ReadLine();
  21. if (vanBenneMaganhangzo(szo))
  22. {
  23. Console.WriteLine("Van benne magánhangzó! ");
  24. }
  25. else
  26. {
  27. Console.WriteLine("Nincs benne!");
  28. }
  29.  
  30.  
  31. while (!sr.EndOfStream)
  32. {
  33. szavak.Add(sr.ReadLine());
  34. }
  35. Console.WriteLine("2. feladat");
  36. string leghosszabb = "";
  37. foreach (string s in szavak)
  38. {
  39. if (s.Length > leghosszabb.Length)
  40. {
  41. leghosszabb = s;
  42. }
  43. }
  44. Console.WriteLine("A leghosszab szó: " + leghosszabb);
  45. Console.WriteLine("A leghosszabb szó: " + leghosszabb.Length + " betűből áll");
  46. Console.WriteLine("3.feladat");
  47.  
  48.  
  49. Console.ReadKey();
  50. }
  51. //main vége
  52. static bool vanBenneMaganhangzo(string s)
  53. {
  54. foreach ( char c in s)
  55. {
  56. if (c == 'a' || c == 'e' || c =='i' || c== 'o' || c == 'u')
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. /*static void leghosszabbSzo(List<string> sz)
  64. {
  65. string leghosszabb = "";
  66. foreach (string s in sz)
  67. {
  68. if(s.Length > leghosszabb.Length)
  69. {
  70. leghosszabb = s;
  71. }
  72. }
  73. Console.WriteLine("A leghosszab szó: " + leghosszabb);
  74. Console.WriteLine("A leghosszabb szó: "+leghosszabb.Length+" betűből áll");
  75. }*/
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement