亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? datastringdeal.java

?? 做了一個還算復雜的計算器,還是有一定的 參考價值的(比較適合中初級者)
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/**
 * @(#)DataStringDeal.java
 *
 *
 * @author 
 * @version 1.00 2007/5/12
 */

//表達式字符串處理類
import java.util.*;
import java.awt.*;
import javax.swing.*; 
public class DataStringDeal{
    private String[] string;
    private int count;
    public DataStringDeal() {
    }
    public DataStringDeal(String[] string,int count){
    	this.string = string;
    	this.count = count;
    }
    public String doOperation(){
    	int leftNum = 0;
    	int rightNum = 0;
    	//以下代碼是用來檢驗表達式的合法性
    	//以及檢驗該表達式是否具有歧義
    	
    	//對括號合法性的檢測
    	for (int i=0;i<=count;i++){
    	    if (string[i]=="(")
    	    	leftNum++;
    	    if (string[i]==")")
    			rightNum++;
    		if (leftNum<rightNum)
    			return "The expression is not valid!";
    	}
    	if (leftNum!=rightNum)
    		return "The expression is not valid!";
    	for (int i=0;i<=count;i++){
        	//對指數運算的檢查
        	if (string[i]=="^"){
        	    if (i==0)
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
        	    if (i==count)
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
        	    if (string[i+1]=="log"||string[i+1]=="n!"||string[i+1]==")"||string[i+1]=="^"||string[i+1]=="+"
        	    	||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/"||string[i+1]==")")
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
        	    if ((string[i+2]=="log"||string[i+2]=="^")&&((i+2)<=count))
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
        	}
        	//對LOG的檢查
        	if (string[i]=="log"){
        		if (i==0)
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
        	    if (i==count)
        	    	return "The Expression is not valid or may be misconceived!\rYou must enter the start button to restart!";
        	    if (string[i+1]=="log"||string[i+1]=="n!"||string[i+1]==")"||string[i+1]=="^"||string[i+1]=="+"
        	    	||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/"||string[i+1]==")")
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
        	    if ((string[i+2]=="log"||string[i+2]=="^")&&((i+2)<=count))
        	    	return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
        	}
        	//對N!的檢查
            if (string[i]=="n!"){
            	if (i==0)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if ((Double.parseDouble(string[i-1])-(int)(Double.parseDouble(string[i-1])))!=0||Double.parseDouble(string[i-1])<0)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if ((string[i+1]!="+"&&string[i+1]!="-"&&string[i+1]!="*"&&string[i+1]!="/"&&string[i+1]!=")")&&(i<=count-1))
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            //對LN的檢查
            if (string[i]=="ln"){
            	if (i==count)
            	    return "The Expression is not valid"+ '\n'+"or may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="log"||string[i+1]=="^"||string[i+1]==")")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";	
            }
            //對sqrt的檢查
            if (string[i]=="sqrt"){
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            //對sqr的檢查
            if (string[i]=="sqr"){
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            //對cos的檢查
            if (string[i]=="cos"){
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            //對sin的檢查
            if (string[i]=="sin"){
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            //左括號的檢查
            if (string[i]=="("){
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            //對右括號的檢查
            if (string[i]==")"){
            	if (i==1)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (i<count)
            	    if (string[i+1]!="+"&&string[i+1]!="-"&&string[i+1]!="*"&&string[i+1]!="/"&&string[i+1]!=")"
            		    &&string[i+1]!="^"&&string[i+1]!="log")
            		    return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            }
            
            //對加號的檢查
            if (string[i]=="+") {
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
            }
            //對減號的檢查
            if (string[i]=="-") {
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
            }
            //對乘號的檢查
            if (string[i]=="*") {
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
            }
            //對除號的檢查
            if (string[i]=="/") {
            	if (i==count)
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]==")"||string[i+1]=="log"||string[i+1]=="^")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            	if (string[i+1]=="+"||string[i+1]=="-"||string[i+1]=="*"||string[i+1]=="/")
            		return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
            }
            
    	}	
    	//以上代碼是用來檢查表達式是否合法
        //如果有括號,進行處理的情況
        if (leftNum > 0){
            int num = 0;
            int[] list = new int[10];//記錄左括號的位置 
            for (int i=0;i<=count;i++){
            	if (string[i]=="("){
            	    if (num>=list.length){
            	    	int[] temp = new int[list.length*2];
            	    	for (int k=0;k<list.length;k++)
            	    		temp[k]=list[k];
            	    	list=temp;
            	    }
            		list[num]=i;
            		num++;
            	}
            	if(string[i]==")"){
            		num--;
            		//下面的FOR語句是計算左右括號內的值
            		for (int j=list[num]+1;j<i;j++){
            			if (string[j]=="n!"){
            				double data = Double.parseDouble(string[j-1]);
            				if ((data-(int)data)!=0)
            					return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";
            				if (data<0)
            					return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!";   
            				for (double fac=data-1;fac>0;fac--){
            					data = data*fac;
            				}
            				String dataString = String.valueOf(data);
            				string[j-1]=dataString;
            				for (int p=j;p<count;p++)
            					string[p]=string[p+1];
            				count=count-1;
            				i=i-1;
            			}
            			if (string[j]=="log"){
            				int p=j+1;//p是用來記錄第一個得到的數字的數組位置
            				while (string[p]=="sin"||string[p]=="cos"||string[p]=="ln"||string[p]=="sqr"||string[p]=="sqrt")
            					p++;
            				double data = Double.parseDouble(string[p]);
            				if (data<=0)
            					return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
            				if (Double.parseDouble(string[j-1])<=0||Double.parseDouble(string[j-1])==1)
            					return "The Expression is not valid \nor may be misconceived!\nYou must enter the start button to restart!"; 
            				p--;
            				int save=p;
            				for (;p>j;p--){
            					if (string[p]=="sin")
            						data=Math.sin(data);
            					if (string[p]=="cos")
            						data=Math.cos(data);
            					if (string[p]=="ln")
            						data=Math.log(data);
            					if (string[p]=="sqr")
            						data=Math.pow(data,2);
            					if (string[p]=="sqrt")
            						data=Math.sqrt(data);
            				}
            				data = Math.log10(data)/Math.log10(Double.parseDouble(string[j-1]));
            				String dataString = String.valueOf(data);
            				string[j-1]=dataString;
            				for (int m=j;m<count-(save-j+1);m++)
            					string[m]=string[m+save-j+2];
            				count=count-(save-j+2);
            				i=i-(save-j+2);
            			}
            			if (string[j]=="^"){
            				int p=j+1;//p是用來記錄第一個得到的數字的數組位置
            				while (string[p]=="sin"||string[p]=="cos"||string[p]=="ln"||string[p]=="sqr"||string[p]=="sqrt")
            					p++;
            				double data = Double.parseDouble(string[p]);
            				p--;
            				int save=p;
            				for (;p>j;p--){
            					if (string[p]=="sin")
            						data=Math.sin(data);
            					if (string[p]=="cos")
            						data=Math.cos(data);
            					if (string[p]=="ln")
            						data=Math.log(data);
            					if (string[p]=="sqr")
            						data=Math.pow(data,2);
            					if (string[p]=="sqrt")
            						data=Math.sqrt(data);
            				}
            				data = Math.pow(Double.parseDouble(string[j-1]),data);
            				String dataString = String.valueOf(data);
            				string[j-1]=dataString;
            				for (int m=j;m<count-(save-j+1);m++)
            					string[m]=string[m+save-j+2];
            				count=count-(save-j+2);
            				i=i-(save-j+2);
            			}
            			if (string[j]=="sin"){
            				int p=j+1;//p是用來記錄第一個得到的數字的數組位置
            				while (string[p]=="sin"||string[p]=="cos"||string[p]=="ln"||string[p]=="sqr"||string[p]=="sqrt")
            					p++;
            				double data = Double.parseDouble(string[p]);
            				p--;
            				int save=p;
            				for (;p>j;p--){
            					if (string[p]=="sin")
            						data=Math.sin(data);
            					if (string[p]=="cos")
            						data=Math.cos(data);
            					if (string[p]=="ln")
            						data=Math.log(data);
            					if (string[p]=="sqr")
            						data=Math.pow(data,2);
            					if (string[p]=="sqrt")
            						data=Math.sqrt(data);
            				}
            				data = Math.sin(data);
            				String dataString = String.valueOf(data);
            				string[j]=dataString;
            				for (int m=j+1;m<count-(save-j);m++)
            					string[m]=string[m+save-j+1];
            				count=count-(save-j+1);
            				i=i-(save-j+1);
            			}
            			if (string[j]=="cos"){
            				int p=j+1;//p是用來記錄第一個得到的數字的數組位置
            				while (string[p]=="sin"||string[p]=="cos"||string[p]=="ln"||string[p]=="sqr"||string[p]=="sqrt")
            					p++;
            				double data = Double.parseDouble(string[p]);
            				p--;
            				int save=p;
            				for (;p>j;p--){
            					if (string[p]=="sin")
            						data=Math.sin(data);
            					if (string[p]=="cos")
            						data=Math.cos(data);
            					if (string[p]=="ln")
            						data=Math.log(data);
            					if (string[p]=="sqr")
            						data=Math.pow(data,2);
            					if (string[p]=="sqrt")
            						data=Math.sqrt(data);
            				}
            				data = Math.cos(data);
            				String dataString = String.valueOf(data);
            				string[j]=dataString;
            				for (int m=j+1;m<count-(save-j);m++)
            					string[m]=string[m+save-j+1];
            				count=count-(save-j+1);
            				i=i-(save-j+1);
            			}
            			if (string[j]=="sqr"){
            				int p=j+1;//p是用來記錄第一個得到的數字的數組位置
            				while (string[p]=="sin"||string[p]=="cos"||string[p]=="ln"||string[p]=="sqr"||string[p]=="sqrt")
            					p++;
            				double data = Double.parseDouble(string[p]);
            				p--;
            				int save=p;
            				for (;p>j;p--){
            					if (string[p]=="sin")
            						data=Math.sin(data);
            					if (string[p]=="cos")
            						data=Math.cos(data);
            					if (string[p]=="ln")
            						data=Math.log(data);
            					if (string[p]=="sqr")
            						data=Math.pow(data,2);
            					if (string[p]=="sqrt")
            						data=Math.sqrt(data);
            				}
            				data = Math.pow(data,2);
            				String dataString = String.valueOf(data);
            				string[j]=dataString;
            				for (int m=j+1;m<count-(save-j);m++)
            					string[m]=string[m+save-j+1];
            				count=count-(save-j+1);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久福利资源站| 久久久99久久精品欧美| 中文字幕一区二区三区乱码在线 | 欧美三电影在线| 久久99热这里只有精品| 在线成人高清不卡| 亚洲影视资源网| 日本韩国精品在线| 亚洲色图.com| 在线视频一区二区免费| 亚洲在线视频网站| 欧美日韩在线三级| 一区二区欧美国产| 国产成人免费xxxxxxxx| 久久网这里都是精品| 国产精品一级片| 国产午夜亚洲精品羞羞网站| 成人在线视频首页| 日本一区二区三区高清不卡| 99久久免费国产| 伊人性伊人情综合网| 欧美亚洲动漫制服丝袜| 人禽交欧美网站| 久久久噜噜噜久久中文字幕色伊伊 | 国产成人aaa| 国产精品人成在线观看免费| 成人午夜在线免费| 亚洲精品视频在线看| 欧美美女bb生活片| 黄页视频在线91| 国产精品久久久久国产精品日日| 91浏览器在线视频| 亚洲激情av在线| 欧美日韩免费电影| 蜜臀av一区二区在线观看| 精品少妇一区二区三区日产乱码| 国产精品一区二区黑丝| 亚洲人妖av一区二区| 91精品国产欧美一区二区成人 | 色狠狠综合天天综合综合| 日韩高清在线不卡| 日韩欧美一区二区视频| 国产99久久久国产精品免费看 | 日韩一区二区麻豆国产| 盗摄精品av一区二区三区| 亚洲乱码中文字幕| 欧美电视剧免费全集观看| 不卡视频一二三| 午夜精品视频一区| 国产精品无人区| 91精品欧美久久久久久动漫 | 日韩一区二区三区四区| 国产福利一区在线| 午夜精品福利久久久| 国产片一区二区| 欧美日韩日本视频| 国产98色在线|日韩| 亚洲一区二区精品视频| 久久久久久久综合日本| 欧美日韩一级片在线观看| 国产经典欧美精品| 午夜精品123| 亚洲色图欧洲色图| 久久蜜桃一区二区| 欧美日韩精品高清| 成人av集中营| 精品在线观看视频| 午夜久久久久久电影| 国产精品高潮久久久久无| 精品国产在天天线2019| 91.麻豆视频| 精品欧美一区二区三区精品久久| 国产91丝袜在线观看| 乱一区二区av| 天使萌一区二区三区免费观看| 中文在线资源观看网站视频免费不卡| 91精品国产综合久久久久久久| 一本色道久久综合狠狠躁的推荐| 国产成人免费在线观看不卡| 理论片日本一区| 五月天丁香久久| 亚洲成a人v欧美综合天堂| 亚洲女性喷水在线观看一区| 中文字幕国产一区二区| 久久亚洲精精品中文字幕早川悠里 | 国产成人精品网址| 国产在线国偷精品产拍免费yy| 视频一区二区三区在线| 一区二区三区在线观看动漫| 亚洲欧美aⅴ...| 亚洲精品亚洲人成人网在线播放| 欧美不卡一区二区三区四区| 欧美一个色资源| 日韩欧美中文字幕一区| 日韩一区二区三区在线| 91精品国产综合久久久蜜臀图片| 欧美疯狂性受xxxxx喷水图片| 99在线视频精品| 91热门视频在线观看| 色欧美88888久久久久久影院| 在线免费亚洲电影| 欧美色综合久久| 色999日韩国产欧美一区二区| 91女人视频在线观看| 日本电影欧美片| 欧美性高清videossexo| 欧美三级在线看| 欧美一二三在线| 精品国产乱码久久久久久影片| 欧美精品一区视频| 国产日韩欧美不卡在线| 国产精品久久国产精麻豆99网站| 国产精品五月天| 亚洲激情第一区| 日韩成人一区二区| 青青青爽久久午夜综合久久午夜 | 717成人午夜免费福利电影| 91精品国产综合久久香蕉麻豆 | 91视频精品在这里| 欧美视频一区二区在线观看| 日韩一级二级三级| 国产视频一区在线观看| 亚洲图片欧美激情| 亚洲一区二区视频| 另类小说欧美激情| 成人性生交大片| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 国产精品无遮挡| 日韩电影免费在线看| 99精品视频一区| 久久亚洲一区二区三区四区| 午夜免费久久看| 波多野结衣在线一区| 欧美一区二区三区公司| 日韩美女啊v在线免费观看| 精品一区二区三区蜜桃| 欧美日韩精品福利| 亚洲欧美日本在线| 成人激情免费网站| 精品国产乱码久久久久久老虎| 亚洲综合区在线| 99re成人在线| 欧美国产精品中文字幕| 蜜臀av国产精品久久久久| 在线视频你懂得一区| 国产精品免费久久| 国产一区二区三区美女| 日韩网站在线看片你懂的| 一区二区国产视频| 99精品视频一区二区| 国产精品女主播av| 国产黄色成人av| 久久久久久久网| 欧美日韩在线不卡| 亚洲精品久久久蜜桃| 成人精品鲁一区一区二区| 26uuu亚洲综合色| 久久精品国产免费| 日韩欧美一级二级三级久久久 | 欧美aaaaaa午夜精品| 精品视频免费在线| 亚洲午夜免费视频| 欧美综合久久久| 亚洲一区二区三区三| 色菇凉天天综合网| 一区二区在线观看av| 欧洲av一区二区嗯嗯嗯啊| 亚洲欧美日韩成人高清在线一区| 99精品国产99久久久久久白柏| 国产精品美日韩| 9色porny自拍视频一区二区| 亚洲视频一区二区免费在线观看| 97久久精品人人爽人人爽蜜臀| 亚洲手机成人高清视频| 日本精品裸体写真集在线观看| 亚洲精品一卡二卡| 欧美色欧美亚洲另类二区| 亚洲成人资源网| 欧美一区日韩一区| 极品少妇一区二区三区精品视频 | 石原莉奈一区二区三区在线观看| 欧美蜜桃一区二区三区| 男男成人高潮片免费网站| 26uuu国产日韩综合| 国产不卡视频在线播放| 18成人在线观看| 欧美日韩免费观看一区三区| 蜜臀av一级做a爰片久久| 久久久久久久久伊人| 97se亚洲国产综合自在线不卡| 亚洲小少妇裸体bbw| 日韩一区和二区| 国产91精品精华液一区二区三区| 中文字幕在线观看一区二区| 在线视频国内自拍亚洲视频| 石原莉奈在线亚洲二区| 国产日本亚洲高清| 91黄色免费版| 狠狠色伊人亚洲综合成人| 综合色天天鬼久久鬼色|