Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 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 _5
  8. {
  9. class Program
  10. {
  11. static int SumujParzyste(int n)
  12. {
  13. int suma = 0;
  14. for (int i = 0; i <= n; i++)
  15. {
  16.  
  17. if (i%2==0)
  18. suma = suma + i;
  19.  
  20.  
  21.  
  22. }
  23. return suma;
  24. }
  25.  
  26. static void Main(string[] args)
  27. {
  28. Random r = new Random();
  29.  
  30. int a = r.Next(1, 11);
  31.  
  32.  
  33. for (int i = 0; i < 10; i++)
  34. {
  35.  
  36. a = r.Next(1, 11);
  37.  
  38. Console.WriteLine("Zsumowowane liczby: " + SumujParzyste(a));
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. Console.ReadKey();
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement