Coder Social home page Coder Social logo

cs-calculator's People

Contributors

areaeffectcloud avatar

Watchers

 avatar

cs-calculator's Issues

冪乗

階乗の計算方式を応用する
ex. 正規表現 など

πの実数表現

πを、

  • 三角関数の中に含まれる時には、実数に変換せず計算する
  • それ以外の時は、Math.PI に変換してから計算する

根号

冪乗の 1/2乗 ver

4桁まで計算 ex. √1600 = 40
(演算子有も含めるので、計8つ書く)

@"[√](\d{1})[+-×÷]"
@"[√](\d{2})[+-×÷]"
@"[√](\d{3})[+-×÷]"
@"[√](\d{4})[+-×÷]"

階乗

正規表現を使った文字列の検索でいい感じに抽出できないか。
使用しているメソッドでは 170! までしか計算ができないので、3桁まで検索をかけている

^(\d{任意の数字})? で桁数を指定可能

//1桁
var match_1 = Regex.Matches(pattern, @"^(\d{1})?[!]");
foreach (Match match_factr1 in match_1)
{
    Console.WriteLine("正規表現 1 : " + match_factr1.Value);
}
//演算子有
var match_1_ope = Regex.Matches(pattern, @"[+-×÷]\d[!]");
foreach (Match match_factr1_ope in match_1_ope)
{
    Console.WriteLine("正規表現 1 a: " + match_factr1_ope.Value);
}

//2桁
var match_2 = Regex.Matches(pattern, @"^(\d{2})?[!]");
foreach (Match match_factr2 in match_2)
{
    Console.WriteLine("正規表現 2 : " + match_factr2.Value);
}
//演算子有
var match_2_ope = Regex.Matches(pattern, @"[+-×÷]\d\d[!]");
foreach (Match match_factr2_ope in match_2_ope)
{
    Console.WriteLine("正規表現 2 a : " + match_factr2_ope.Value);
}

//3桁
var match_3 = Regex.Matches(pattern, @"\d\d\d[!]");
foreach (Match match_factr3 in match_3)
{
    Console.WriteLine("正規表現 3桁 : " + match_factr3.Value);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.