佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1281|回复: 15

Java 问题

  [复制链接]
发表于 17-10-2010 08:40 PM | 显示全部楼层 |阅读模式
本帖最后由 chris_cs 于 17-10-2010 10:07 PM 编辑

//Enter the function (real of one variable x).

f (x) =2*x^2       (can key in any function) eg. 2*x+2, X^2, .... etc 一百亿可能
X= 2                  (key in x valve)
result = 8

各位大大,如何用java作这样program??


if i use

Double a , x ;
a = 2 * math.pow( x ,  2.0 ) ;
兔仙人 发表于 17-10-2010 08:48 PM

the my program need type 一百亿个 Case ??
please 看清楚。
回复

使用道具 举报


ADVERTISEMENT

发表于 17-10-2010 08:48 PM | 显示全部楼层
Double a , x ;
a = 2 * math.pow( x ,  2.0 ) ;
回复

使用道具 举报

 楼主| 发表于 17-10-2010 08:52 PM | 显示全部楼层
Double a , x ;
a = 2 * math.pow( x ,  2.0 ) ;
兔仙人 发表于 17-10-2010 08:48 PM



   我can key in ANY (random) function with x valve,
example
2*x+2
x^2+2
x^2+2*x+3
... etc
回复

使用道具 举报

发表于 17-10-2010 09:01 PM | 显示全部楼层
有点复杂 =.=||
回复

使用道具 举报

发表于 17-10-2010 09:17 PM | 显示全部楼层
连JAVA 书/教程的前几章都没看或搞懂就来问吗?
回复

使用道具 举报

 楼主| 发表于 17-10-2010 09:24 PM | 显示全部楼层
连JAVA 书/教程的前几章都没看或搞懂就来问吗?
jasonmun 发表于 17-10-2010 09:17 PM



    那一章,请说。。
java scan Algebra function?
or array function?
回复

使用道具 举报

Follow Us
发表于 17-10-2010 09:59 PM | 显示全部楼层
回复 6# chris_cs

2 楼那个不就是答案吗?? =.=|||
回复

使用道具 举报

发表于 17-10-2010 09:59 PM | 显示全部楼层
這已經是algorithm的東西了 =.=
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 17-10-2010 10:02 PM | 显示全部楼层
回复  chris_cs

2 楼那个不就是答案吗?? =.=|||
宅男-兜着走 发表于 17-10-2010 09:59 PM



请看清楚。
    can key in any function!!!

mean i can key x^2+5 , 2*x+5, x^3+3..... etc   一亿个可能。
回复

使用道具 举报

发表于 17-10-2010 10:31 PM | 显示全部楼层
请看清楚。
    can key in any function!!!

mean i can key x^2+5 , 2*x+5, x^3+3..... etc   一 ...
chris_cs 发表于 17-10-2010 10:02 PM


https://eval.dev.java.net/

可以多多利用这个 Library。
你的一亿种可能也能简单达到。
回复

使用道具 举报

 楼主| 发表于 17-10-2010 10:47 PM | 显示全部楼层
可以多多利用这个 Library。
你的一亿种可能也能简单达到。
宅男-兜着走 发表于 17-10-2010 10:31 PM



if u assign
string a =   (key in function)
then how you convert to "operation algorithms" is a main key.
回复

使用道具 举报

发表于 17-10-2010 11:02 PM | 显示全部楼层
本帖最后由 宅男-兜着走 于 17-10-2010 11:05 PM 编辑
if u assign
string a =   (key in function)
then how you convert to "operation algorithms" i ...
chris_cs 发表于 17-10-2010 10:47 PM


import net.java.dev.eval.Expression;import java.math.BigDecimal;
import java.util.Map;
import java.util.HashMap;

public class EvaluationClass {

    public static void main(String[] args) {        
        String str = "2 * x ^ 2";
        str = str.replace("^" , "pow");      
        Expression exp = new Expression(str);                  
        Map<String, BigDecimal> variables = new HashMap<String, BigDecimal>();     

        variables.put("x", new BigDecimal("2"));
        BigDecimal result = exp.eval(variables);                  
        System.out.println(result);                   }
}
   
写好给你了。 自己去下载那个 EVAL Library。

研究了才来做定论。
回复

使用道具 举报

 楼主| 发表于 17-10-2010 11:18 PM | 显示全部楼层
回复 12# 宅男-兜着走


    谢谢!
比我的来的简单。。。。

我的还要scan  math operation(+,-,*,/,pow,....) & Algebraic (x,y,z,a,b,c)
then covert string into array,
some-more call out array data  into new var (result=2*x+5)

thanks


beside
got 1 tools 专门来 solve  equation 的 import library (but need $$)


回复

使用道具 举报

发表于 17-10-2010 11:28 PM | 显示全部楼层
回复  宅男-兜着走


    谢谢!
比我的来的简单。。。。

我的还要scan  math operation(+,-,*,/,p ...
chris_cs 发表于 17-10-2010 11:18 PM


那个要钱的是哪一个? 我看看下。
回复

使用道具 举报

 楼主| 发表于 17-10-2010 11:39 PM | 显示全部楼层
回复 14# 宅男-兜着走


    give u this program link ,make by 别人 (VB.net)
http://wims.unice.fr/wims/wims.cgi?session=KP8627B57B.2&+lang=en&+module=tool%2Fanalysis%2Ffunction.en
回复

使用道具 举报

发表于 18-10-2010 10:52 AM | 显示全部楼层
这个问题 , 你必须 IMPORT 一些 LIBRARY 才可以做到 。 因为 有那么多 OPERATOR , 你没有可能一个个去VALIDATE 它 。
回复

使用道具 举报


ADVERTISEMENT

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 18-11-2025 06:07 AM , Processed in 0.134374 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表