static void Main(string[] args) { string text = " ((((( )))))"; Console.WriteLine(AdvancedCalculator.CountAppearance(text, '(')); Console.WriteLine(text); }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <returns></returns> public static Queue <string> GetCalculation(string text) { string noSpaces = AdvancedCalculator.RemoveSpaces(text); string calculation = AdvancedCalculator.RemoveStartAndEndBrackets(noSpaces); int countStartBrackets = AdvancedCalculator.CountAppearance(calculation, '('); int countEndBrackets = AdvancedCalculator.CountAppearance(calculation, ')'); if (countEndBrackets == countStartBrackets) { int operations = AdvancedCalculator.CountAppearance(calculation, '+') + AdvancedCalculator.CountAppearance(calculation, '-') + AdvancedCalculator.CountAppearance(calculation, '*') + AdvancedCalculator.CountAppearance(calculation, '/'); } return(null); }
public static Fraction ConvertToDouble(double d) { string str = d.ToString(); if (!str.Contains('.')) { str += "."; } string[] vs = str.Split('.'); int afterPoint = vs[1].Length + 1; int newNumerator; int newDenumrator; if (afterPoint <= 8) { newNumerator = (int)(d * 0.1 * AdvancedCalculator.Power(10, afterPoint)); newDenumrator = (int)(0.1 * AdvancedCalculator.Power(10, afterPoint)); } else { newNumerator = (int)(d * AdvancedCalculator.Power(10, 8)); newDenumrator = AdvancedCalculator.Power(10, 8); } return(new Fraction(newNumerator, newDenumrator)); }