Sybatron

ConsoleApplicationForLoop01

Sep 26th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace PossitivesEvenNums
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.Write("Въведете n: ");
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             int brChet = 0;
  16.             int sumPol = 0;
  17.  
  18.             for (int i = 1; i <= n; i++)
  19.             {
  20.                 Console.Write("Въведете {0}-то число: ",i);
  21.                 int num = int.Parse(Console.ReadLine());
  22.  
  23.                 if (num > 0)
  24.                 {
  25.                     sumPol += num;
  26.                 }
  27.                 if (num % 2 == 0)
  28.                 {
  29.                     brChet++;
  30.                 }
  31.             }
  32.  
  33.             Console.WriteLine("Сумата на положителните числа е: {0}",sumPol);
  34.             Console.WriteLine("Брося на четните числа е: {0}", brChet);
  35.             Console.Write("\nНатиснете клавиш.....");
  36.             Console.ReadKey();
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment