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 zadanie1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int a, b;
- Console.WriteLine("Podaj a: ");
- a = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Podaj b: ");
- b = Convert.ToInt32(Console.ReadLine());
- int suma = 0;
- int suma2 = 0;
- int mnozenie = 0;
- Parallel.Invoke(
- () =>
- {
- for(int i = a; i <= b; i++)
- {
- if (i % 3 == 0)
- {
- suma += i;
- }
- }
- },
- () =>
- {
- mnozenie = a * b;
- string zmienna = mnozenie.ToString();
- for (int i = 0; i<zmienna.Length; i++)
- {
- suma2 += Convert.ToInt32(zmienna[i].ToString());
- }
- }
- );
- Console.WriteLine("suma liczb w przedziale podzielnych przez 3 wynosi: {0}", suma);
- Console.WriteLine("mnozenie: {0}", mnozenie);
- Console.WriteLine("Suma cyfr: {0}", suma2);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement