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;
- using System.Threading;
- namespace Kolokwium
- {
- class Program
- {
- static void Main(string[] args)
- {
- int x, y;
- Console.Write("Podaj pierwszą liczbę");
- int.TryParse(Console.ReadLine(), out x);
- Console.Write("Podaj drugą liczbę");
- int.TryParse(Console.ReadLine(), out y);
- Parallel.Invoke(
- () =>
- {
- int sum = 0;
- for (int i = x; i < y; i++)
- {
- if ( (i % 3) == 0)
- {
- sum += i;
- }
- }
- Console.WriteLine("---");
- Console.WriteLine("Suma liczb z zakresu {0} - {1} podzielnych przez 3 jest równa: {2}", x, y, sum);
- Console.WriteLine("---");
- },
- () =>
- {
- int sum = 0;
- sum = x * y;
- string number = sum.ToString();
- sum = 0;
- foreach (char c in number)
- {
- sum += int.Parse(c.ToString());
- }
- Console.WriteLine("---");
- Console.WriteLine("Suma cyfr w liczbie będącej iloczynem liczb: {0} i {1} wynosi: {2}", x, y, sum);
- Console.WriteLine("---");
- }
- );
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement