Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.  
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Podaj rozmiar: ");
  14. string liczba = Console.ReadLine();
  15.  
  16. int rozmiar = int.Parse(liczba);
  17.  
  18. int[] tab = new int[10];
  19. for(int i=0;i<rozmiar;i++)
  20. {
  21. Console.WriteLine("Podaj liczbe: ");
  22. string numer = Console.ReadLine();
  23. int parsednumer = int.Parse(liczba);
  24. tab[i] = parsednumer;
  25. }
  26. wlasciwosci(tab);
  27.  
  28.  
  29. void wlasciwosci(int[] tab)
  30. {
  31. Console.WriteLine("Suma: ");
  32. Console.WriteLine(sumaElementow(tab));
  33.  
  34. }
  35.  
  36.  
  37. int sumaElementow(int[] tab)
  38. {
  39. int sum = 0;
  40. for(int i=0;i<rozmiar;i++)
  41. {
  42. sum += tab[i];
  43. }
  44. return sum;
  45. }
  46.  
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement