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;
- namespace Počet_kladných_a_záporných
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Zadejte 10 kladných / záporných čísel: ");
- int pocet = 10;
- int[] cisla = new int[pocet];
- for (int i = 0; i < pocet; i++)
- {
- Console.WriteLine("Vlož číslo: ");
- int soucasne = int.Parse(Console.ReadLine());
- cisla[i] = soucasne;
- }
- int negativni = 0;
- int positivni = 0;
- foreach (int i in cisla)
- {
- if (i < 0)
- {
- negativni++;
- }
- if (i > 0)
- {
- positivni++;
- }
- }
- Console.WriteLine("Kladných je: {0}", positivni);
- Console.WriteLine("Záporných je: {0}", negativni);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement