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;
- namespace exception_numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- string s = Console.ReadLine();
- string[] arr = s.Split(' ');
- try
- {
- for (int i = 0; i < arr.Length; i++)
- {
- Console.Write(arr[i] + " ");
- double n = double.Parse(arr[i]);
- if (n <= 0)
- throw new Exception();
- // OK, прекрасная идея, но лучше бросать, да и ловить не Exception вообще,
- // а что-нибудь специализированное, например FormatException
- }
- Console.WriteLine("Да");
- }
- catch (Exception)
- {
- Console.WriteLine("Нет");
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment