Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 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 Počet_kladných_a_záporných
  14.  
  15. {
  16.  
  17. class Program
  18.  
  19. {
  20.  
  21. static void Main(string[] args)
  22.  
  23. {
  24.  
  25. Console.Write("Zadejte 10 kladných / záporných čísel: ");
  26.  
  27. int pocet = 10;
  28.  
  29.  
  30.  
  31. int[] cisla = new int[pocet];
  32.  
  33.  
  34.  
  35. for (int i = 0; i < pocet; i++)
  36.  
  37. {
  38.  
  39. Console.WriteLine("Vlož číslo: ");
  40.  
  41. int soucasne = int.Parse(Console.ReadLine());
  42.  
  43.  
  44.  
  45. cisla[i] = soucasne;
  46.  
  47. }
  48.  
  49. int negativni = 0;
  50.  
  51. int positivni = 0;
  52.  
  53.  
  54.  
  55. foreach (int i in cisla)
  56.  
  57. {
  58.  
  59. if (i < 0)
  60.  
  61. {
  62.  
  63. negativni++;
  64.  
  65. }
  66.  
  67.  
  68.  
  69. if (i > 0)
  70.  
  71. {
  72.  
  73. positivni++;
  74.  
  75. }
  76.  
  77. }
  78.  
  79.  
  80.  
  81. Console.WriteLine("Kladných je: {0}", positivni);
  82.  
  83. Console.WriteLine("Záporných je: {0}", negativni);
  84.  
  85.  
  86.  
  87. Console.ReadLine();
  88.  
  89.  
  90.  
  91.  
  92.  
  93. }
  94.  
  95. }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement