Advertisement
BloodMoonYTC

poz+neg

Oct 24th, 2021
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace pozitiv_negativosszege
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Kólity Kristóf");
  10.             int szam, poz = 0, neg = 0;
  11.  
  12.             Console.Write("Hany szamot akarsz bevinni : ");
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             Console.WriteLine("Irj be " + n + " számot");
  16.             for (int i = 1; i <= n; i++)
  17.             {
  18.                 szam = int.Parse(Console.ReadLine());
  19.                 if (szam > 0)
  20.                     poz += szam;
  21.                 else
  22.                     neg += szam;
  23.             }
  24.             Console.WriteLine("A bevitt pozitiv szamok osszege : " + poz);
  25.             Console.WriteLine("A bevitt negativ szamok osszege : " + neg);
  26.             Console.ReadLine();
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement