Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Cwiczenia_1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Hello World!");
- }
- }
- class Zadanie_4
- {
- static void zadanie1()
- {
- int n;
- int i;
- int j; //przeksztalcanie wczytanego napisu na integer
- Console.Write("Podaj n:");
- if (!Int32.TryParse(Console.ReadLine(), out n) || n < 3 || n % 2 == 0)
- {
- Console.WriteLine("Błędna wartość. {n}");
- return;
- }//zaszyty mechanizm obslugi wyjatki
- for (i = 0; i < n; ++i)
- {
- Console.Write("* ");
- }
- Console.WriteLine();
- }
- static double Odwrotnosc(double x)
- { double n;
- try
- { x = 1 / n; }
- catch (ArithmeticException e)
- { Console.WriteLine(e.Message); }
- return x;
- }
- static void Test_Zadanie_4()
- {
- double x;
- Console.Write("Podaj n:");
- double.TryParse(Console.ReadLine(), out x);
- if (Math.Abs(x) < 0.001) {
- throw new ArithmeticException("Dzielenie przez 0!!!");
- }
- Console.WriteLine(Odwrotnosc(x));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement