Advertisement
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;
- using System.Threading.Tasks;
- namespace ConsoleApplication26
- {
- class Program
- {
- static Boolean isNum(String sNum)
- {
- try
- {
- int num = Int32.Parse(sNum);
- }
- catch
- {
- return false;
- }
- return true;
- }
- static int getNum(String Msg)
- {
- String Str;
- do
- {
- Console.Write(Msg);
- Str = Console.ReadLine();
- if (!isNum(Str))
- Console.WriteLine("Неверный формат");
- } while (!isNum(Str));
- return Convert.ToInt32(Str);
- }
- static void Main(string[] args)
- {
- int a = getNum("Введите A: ");
- int b = getNum("Введите B: ");
- Console.WriteLine("A + B = "+(a+b));
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement