Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 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 zadanie1._3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. {
  14. poczatek:
  15. Console.WriteLine("użytkowniku, wprowadź mi jakiś przedział liczbowy. ");
  16. Console.WriteLine("Ja powiem Ci, ile w tym przedziale liczbowym jest liczb podzielnych przez ");
  17. Console.WriteLine("wybraną przez Ciebie liczbę.");
  18. Console.WriteLine("Pamiętaj, żeby najpierw wprowadzić liczbę o niższej wartosci.");
  19.  
  20.  
  21. Console.WriteLine("Najpierw wprowadź pierwszą liczbę.");
  22. string liczba1 = Console.ReadLine();
  23. Console.WriteLine("Teraz wprowadź drugą liczbę.");
  24.  
  25. int licznikpodzielnychliczb = 0;
  26. int wynik = 0;
  27. string liczba2 = Console.ReadLine();
  28. int pierwszaliczba = Convert.ToInt32(liczba1);
  29. int drugaliczba = Convert.ToInt32(liczba2);
  30. Console.WriteLine("Na koniec wprowadź liczbę, przez którą mają być podzielne liczby w zbiorze.");
  31. string liczba3 = Console.ReadLine();
  32. int trzecialiczba = Convert.ToInt32(liczba3);
  33. for (int i = pierwszaliczba; i <= drugaliczba; i++)
  34.  
  35. if (i % trzecialiczba == 0)
  36. if (i != 0)
  37. licznikpodzielnychliczb++;
  38. Console.Write("Twój zbiór zawiera ");
  39. Console.WriteLine(licznikpodzielnychliczb);
  40. Console.WriteLine("liczb/ -y podzielnych przez " + liczba3);
  41. Console.WriteLine("Wpisz 'start', żeby sprawdzić kolejny zbiór.");
  42. Console.WriteLine("wpisz 'jakie to liczby', aby zobaczyć poszczególne liczby");
  43. string answer = Console.ReadLine();
  44. if (answer == "start")
  45. goto poczatek;
  46. else if (answer == "jakie to liczby")
  47. {
  48. wynik = 0;
  49. for (int k = pierwszaliczba; k <= drugaliczba; k++)
  50.  
  51. if (k % trzecialiczba == 0)
  52. if (k != 0)
  53. Console.WriteLine(wynik = k);
  54.  
  55. Console.WriteLine("Wpisz 'start', żeby sprawdzić kolejny zbiór");
  56. Console.WriteLine(", lub inny dowolny klawisz aby zakończyć.");
  57. string answer2 = Console.ReadLine();
  58. if (answer2 == "start")
  59. goto poczatek;
  60. else
  61.  
  62. Console.ReadLine();
  63.  
  64.  
  65. }
  66.  
  67.  
  68.  
  69. else
  70.  
  71. {
  72. Console.WriteLine("Naciśnij dowolny przycisk, żeby zakończyć.");
  73. Console.ReadLine();
  74. }
  75. }
  76.  
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement