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 zadanie1._3
- {
- class Program
- {
- static void Main(string[] args)
- {
- {
- poczatek:
- Console.WriteLine("użytkowniku, wprowadź mi jakiś przedział liczbowy. ");
- Console.WriteLine("Ja powiem Ci, ile w tym przedziale liczbowym jest liczb podzielnych przez ");
- Console.WriteLine("wybraną przez Ciebie liczbę.");
- Console.WriteLine("Pamiętaj, żeby najpierw wprowadzić liczbę o niższej wartosci.");
- Console.WriteLine("Najpierw wprowadź pierwszą liczbę.");
- string liczba1 = Console.ReadLine();
- Console.WriteLine("Teraz wprowadź drugą liczbę.");
- int licznikpodzielnychliczb = 0;
- int wynik = 0;
- string liczba2 = Console.ReadLine();
- int pierwszaliczba = Convert.ToInt32(liczba1);
- int drugaliczba = Convert.ToInt32(liczba2);
- Console.WriteLine("Na koniec wprowadź liczbę, przez którą mają być podzielne liczby w zbiorze.");
- string liczba3 = Console.ReadLine();
- int trzecialiczba = Convert.ToInt32(liczba3);
- for (int i = pierwszaliczba; i <= drugaliczba; i++)
- if (i % trzecialiczba == 0)
- if (i != 0)
- licznikpodzielnychliczb++;
- Console.Write("Twój zbiór zawiera ");
- Console.WriteLine(licznikpodzielnychliczb);
- Console.WriteLine("liczb/ -y podzielnych przez " + liczba3);
- Console.WriteLine("Wpisz 'start', żeby sprawdzić kolejny zbiór.");
- Console.WriteLine("wpisz 'jakie to liczby', aby zobaczyć poszczególne liczby");
- string answer = Console.ReadLine();
- if (answer == "start")
- goto poczatek;
- else if (answer == "jakie to liczby")
- {
- wynik = 0;
- for (int k = pierwszaliczba; k <= drugaliczba; k++)
- if (k % trzecialiczba == 0)
- if (k != 0)
- Console.WriteLine(wynik = k);
- Console.WriteLine("Wpisz 'start', żeby sprawdzić kolejny zbiór");
- Console.WriteLine(", lub inny dowolny klawisz aby zakończyć.");
- string answer2 = Console.ReadLine();
- if (answer2 == "start")
- goto poczatek;
- else
- Console.ReadLine();
- }
- else
- {
- Console.WriteLine("Naciśnij dowolny przycisk, żeby zakończyć.");
- Console.ReadLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement