pborawski

Zajęcia z Programowania w środowiskach graficznych lab1

Feb 27th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication4
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.WriteLine("Dodawanie");
  13.             Console.WriteLine("Podaj liczbe");
  14.             int liczba,suma=0;
  15.            
  16.             if (int.TryParse(Console.ReadLine(),out liczba))
  17.             {
  18.                  for ( int i = 1; i<=liczba; i++ )
  19.                  {
  20.                         suma+=i;
  21.                  }
  22.             }
  23.             else
  24.                  Console.WriteLine("Bład!");
  25.  
  26.  
  27.                 Console.WriteLine("1+...+" + liczba + "=" + suma);
  28.  
  29.                 Console.ReadKey();
  30.            
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment