设为首页 加入收藏

TOP

函数绘图(一) (二)
2014-11-23 22:53:52 来源: 作者: 【 】 浏览:8
Tags:函数 绘图
else if (Char(input, '-'))

98 {

99 return new NegExpression

100 {

101 Op = Exp0(input),

102 };

103 }

104 else

105 {

106 double number = Number(input);

107 if (!double.IsNaN(number))

108 {

109 return new NumberExpression

110 {

111 Number = number,

112 };

113 }

114

115 string name = Name(input);

116 if (name == null)

117 {

118 throw new ArgumentException("Error encountered, at " + new string(*input));

119 }

120

121 if (!Char(input, '('))

122 {

123 return new VariableExpression

124 {

125 Name = name,

126 };

127 }

128

129 FunctionExpression f = FunctionExpression.FromName(name);

130 f.Op = Exp3(input);

131 if (!Char(input, ')'))

132 {

133 throw new ArgumentException("Error encountered, at " + new string(*input));

134 }

135 return f;

136 }

137 }

138

139 private static Expression Exp1(char** input)

140 {

141 Expression e = Exp0(input);

142 while (true)

143 {

144 if (Char(input, '^'))

145 {

146 e = new PowerExpression

147 {

148 Left = e,

149 Right = Exp0(input),

150 };

151 }

152 else

153 {

154 break;

155 }

156 }

157 return e;

158 }

159

160 private static Expression Exp2(char** input)

161 {

162 Expression e = Exp1(input);

163 while (true)

164 {

165 if (Char(input, '*'))

166 {

167 e = new MulExpression

168 {

169 Left = e,

170 Right = Exp1(input),

171 };

172 }

173 else if (Char(input, '/'))

174 {

175 e = new DivExpression

176 {

177 Left = e,

178 Right = Exp1(input),

179 };

180 }

181 else

182 {

183 break;

184 }

185 }

186 return e;

187 }

188

189 private static Expression Exp3(char** input)

190 {

191 Expression e = Exp2(input);

192 while (true)

193 {

194 if (Char(input, '+'))

195 {

196 e = new AddExpression

197 {

198 Left = e,

199

首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇 日期/时间校验(yyyyMMddHHmmss) 下一篇hdu 1496 Equations(非常巧妙的h..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: