Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Linq;
  6.  
  7. using System.Text;
  8.  
  9. using System.Threading.Tasks;
  10.  
  11.  
  12.  
  13. namespace Scitani_s_vypisem
  14.  
  15. {
  16.  
  17. class Program
  18.  
  19. {
  20.  
  21. static void Main(string[] args)
  22.  
  23. {
  24. Console.WriteLine("Zadejte počet čísel na sečtení: ");
  25. int pocet = int.Parse(Console.ReadLine());
  26.  
  27. int[] cisla = new int[pocet];
  28.  
  29. for (int i = 0; i < pocet; i++)
  30. {
  31. Console.Write("Zadejte {0}. číslo: ", i + 1);
  32. cisla[i] = int.Parse(Console.ReadLine());
  33. }
  34.  
  35.  
  36.  
  37. for (int i = 0; i < pocet; i++)
  38. if (i + 1 == pocet)
  39. {
  40. Console.Write("{0} = {1} ", cisla[i], cisla.Sum());
  41. }
  42. else
  43. {
  44. Console.Write("{0} + ", cisla[i]);
  45. }
  46.  
  47. Console.ReadKey();
  48.  
  49. }
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement