Sovun

Untitled

Sep 21st, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             bool checkInput = false;
  14.             double m, n = 0;
  15.             Console.WriteLine("Введите исходные данные");
  16.            
  17.             do
  18.             {
  19.                 Console.WriteLine("m?");
  20.                 checkInput = double.TryParse(Console.ReadLine(), out m);
  21.                 if (!checkInput) Console.WriteLine("Неверный формат ввода!");
  22.             } while (!checkInput);
  23.  
  24.            
  25.             do
  26.             {
  27.                 Console.WriteLine("n?");
  28.                 checkInput = double.TryParse(Console.ReadLine(), out n);
  29.                 if (!checkInput) Console.WriteLine("Неверный формат ввода!");
  30.             } while (!checkInput);
  31.  
  32.             Console.WriteLine("Выберите операцию и введите её номер");
  33.             Console.WriteLine("1) n+++m");
  34.             Console.WriteLine("2) m-->n");
  35.             Console.WriteLine("3) n-->m");
  36.             Console.WriteLine("4) sin(n)+(n^3)+1/(n^2+1)");
  37.  
  38.             int switcher;
  39.             do
  40.             {
  41.                 checkInput = int.TryParse(Console.ReadLine(), out switcher);
  42.                 if ((!checkInput) || ((switcher > 4) && (switcher < 1))) Console.WriteLine("Неверный формат ввода!");
  43.             } while (!checkInput);
  44.  
  45.             switch (switcher)
  46.             {
  47.                 case 1:
  48.                    double res = (m++) + n;
  49.                     Console.WriteLine("m=" + (m-1) + " " + "n=" + n + " m+++n="+res);
  50.                     break;
  51.                 case 2:
  52.                     bool res2 = (m--) > n;
  53.                     Console.WriteLine("m=" + (m+1) + " " + "n=" + n + " m-->n="+res2);
  54.                     break;
  55.                 case 3:
  56.                    bool res3 = n-- > m;
  57.                     Console.WriteLine("m=" + m + " " + "n=" + (n+1) + " n-->m=" + res3);
  58.                     break;
  59.                 case 4:
  60.                     //sin(n)+(n^3)+1/(n^2+1)
  61.                     double res4 = Math.Sin(n)+Math.Pow(n,3)+1/(Math.Pow(n, 2)+1);
  62.                     Console.WriteLine("m=" + m + " " + "n=" + n + " m---n="+res4);
  63.                     break;
  64.                // default:
  65.                  //   break;
  66.             }
  67.               string s = Console.ReadLine();
  68.  
  69.  
  70.  
  71.             }
  72.  
  73.  
  74.  
  75.  
  76.         }
  77.     }
Advertisement
Add Comment
Please, Sign In to add comment