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

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

?? mcalc.java

?? 用java實現浮點數加減乘除四則混合運算
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
			break;
		case 8:
			int matchMulti = myStack.search( "[" );
		  if ( matchMulti == -1 )
		  {
				if ( myStack.size() >=2 )
				{
					Object number1 = myStack.pop();
					Object number2 = myStack.pop();

					if ( number1.getClass() == Double.class )
					{
						double num1 = ((Double)number1).doubleValue();
						if ( number2.getClass() == Double.class )
						{
							double num2 = ((Double)number2).doubleValue();
							myStack.push( Matrix.multi( num2,num1)); 
						}
						else if( number2.getClass() == Matrix.class )
						{
							Matrix num2 = ( Matrix )number2;
							myStack.push( Matrix.multi( num2,num1 ));
						}					
					}
					else
					{
						Matrix num1 = ( Matrix )number1;
						if ( number2.getClass() == Double.class )
						{
							double num2 = ((Double)number2).doubleValue();
							myStack.push( Matrix.multi( num2,num1)); 
						}
						else if( number2.getClass() == Matrix.class )
						{
							Matrix num2 = ( Matrix )number2;
							Object result = Matrix.multi( num2,num1 );
							if ( result != null )
							{
								myStack.push( result );
							}						
						}						
					}				
				}
				else
				{
					//運算數字個數不足。
					System.out.println( 
						"Error: There aren't enough operands for multiplication!" );				
				}
			}
			else
			{
				System.out.println( 
					"Error: Unable to do the multiplication inside the matrix!" );			
			}				
			break;
		case 9:
			int matchUnd = myStack.search( "[" );
		  if ( matchUnd == -1 )
		  {
			if ( myStack.size() >= 1 )
			{
			  Object temp = myStack.pop();
				if ( temp.getClass() == Double.class )
				{
					myStack.push( Matrix.negative(((Double)temp).doubleValue()));
				}
				else 
				{
					myStack.push( Matrix.negative((Matrix)temp) );
				}
			}
			else
			{
				//運算數字個數不足。
				System.out.println( "Error: The stack is empty!" );				
			}
			}
			else
			{
				System.out.println( 
					"Unable to do the multiplication inside the matrix!" );
			}
			break;
		case 10:
			int matchTra = myStack.search( "[" );
		  if ( matchTra == -1 )
		  {
			if ( myStack.size() >= 1)
			{		
				Object temp = myStack.pop();
				if ( temp.getClass() == Double.class )
				{
					myStack.push( temp );
				}
				else 
				{					
					temp =  Matrix.transpose((Matrix)temp);
					myStack.push( temp );
				}
			}
			else
			{
				//運算數字個數不足。
				System.out.println( "Error: The stack is empty!" );				
			}
			}
			else
			{
				System.out.println( 
					"Error: Unable to do the operation inside the matrix!" );
			}
			break;
		case 11:
			//數字給相反數,矩陣給逆陣。
	  	int matchInv = myStack.search( "[" );
		  if ( matchInv == -1 )
		  {
	  	if ( myStack.size() > 0 )
			{
			  Object temp = myStack.pop();
				if ( temp.getClass() == Double.class )
				{
					double number = ((Double)temp).doubleValue();
					if ( number == 1.0 || number == 0.0 )
					{
						System.out.println(
							"Error: The number doesn't have an inverse number." );
					}
					else
					{
						myStack.push( Matrix.inverse( number ));
					}
				}
				else 
				{
					if ( Matrix.hasInvMatrix( (Matrix)temp ) )
					{
						myStack.push( Matrix.inverse((Matrix)temp) );
					}
					else
					{
						myStack.push( temp );
						System.out.println( "Error: The matrix hasn't an inverse matrix!" );
					}					
				}
			}
			else
			{
				//運算數字個數不足。
				System.out.println( "Error: The stack is empty!" ); 
			}
			}
			else
			{
				System.out.println( 
					"Error: Unable to do the operation inside the matrix!" );
			}
			break;
		case 12:			
		  String variableTemp = variable;
			char first;
			boolean judge = true;
			
			for ( int i = 0; i < variableTemp.length(); i++ )
			{
				first = variableTemp.charAt( i );

				if ( !Character.isLetterOrDigit( first ) && first != '_' )
				{
					System.out.println( "Error: The variable's name is invalid!" );
					judge = false;
					break;
				}
			}
			if ( judge )
			{
				if ( myStack.size() > 0 )
				{				
					hashtable.put( variable,myStack.pop() );		
					Object temp = hashtable.get( variable );
				}
				else
				{
					//空棧報錯;
					System.out.println( "Error: There is no element in the stack!" );
				}
			}				
					
			break;
    case 13:
			Object temp = hashtable.get( variable );
      if ( temp != null ) 
			{
         myStack.push( temp );
      }
			else
			{
				//報錯,沒有這個變量。
				System.out.println( "Error: No such variable!" );
			} 
			break;
		case 14:
      Object tempValue;
		  if ( myStack.size() == 0 )
		  { 
  			System.out.println( "Error: The stack is empty!" );		
			}
			else
			{
				tempValue = myStack.peek();
		    myStack.push( tempValue );
			}			
			break;
		case 15:
			if ( myStack.size() < 2)
      {
		  	System.out.println( 
					"Error: Less than two elements. Unable to do the exchange!" );
		  }
			else
			{
				Object temp1,temp2;
   
				temp1 = myStack.pop();
				temp2 = myStack.pop();

				myStack.push( temp1 );
				myStack.push( temp2 );
			}
			break;
		case 16:
			if ( myStack.size() > 0 )
			{
				myStack.pop();
			}
			else
			{
				System.out.println( "Error: The stack is empty!" );
			}			
			break;
		case 17:
			System.exit( 0 );
			break;
		case 18:
			System.out.println( "The help for this software:" );
		  System.out.println( "Please input the commands seperated by blanks.\nThe case of letters would be ignored." );
      System.out.println( "The possible commands are as follows:" );
			System.out.println( "#: It marks a comment.Everything to the end of the line is ignored." );
			System.out.println( "N: Read N from the user. N should be a floating-number." );
			System.out.println( "[: Marks the beginning of a matrix or a vector." );
			System.out.println( "]: Create a vector or matrix out of what's on the stack." );
			System.out.println( "The resulting matrix (if valid) is pushed onto the stack." );
			System.out.println( "id N:When N is a positive integer, pushes the N*N identity matrix on the stack." );
			System.out.println( "=: Show you the top element of the stack." );
			System.out.println( "+ - /:pop the top two items on the stack, perform the indicated arithmetic");
			System.out.println( "operation (with the top item of the stack on the right of the operator), " );
			System.out.println( "and push the result back on the stack." );
			System.out.println( "Addition and subtraction are defined between two numbers or two matrices " );
			System.out.println( "of the same dimensions. Division is defined only on numbers. " );
			System.out.println( "*: pops the top two items on the stack and multiplies them (with " );
			System.out.println( "the top item being the right operand), pushing the result back on the " );
			System.out.println( "stack. Multiplication is defined between two numbers, between a number " );
			System.out.println( "and a matrix, and between two conforming matrices (i.e., an m * k matrix " );
			System.out.println( "on the left and a k * n matrix on the right, yielding an m * n matrix). If the " );
			System.out.println( "result is a 1 * 1 matrix, it is treated as a scalar (thus giving dot product)." );
			System.out.println( "_: It negates the top element of the stack (same as multiplying by -1)." );
			System.out.println( "t: Pop the top element of the stack and pushes its transpose. " );
			System.out.println( "inv: Pop the top element of the stack, which must be a square, non-singular " );
			System.out.println( "matrix, and pushes its inverse." );
			System.out.println( "=: V:Pop the top of the stack and save it in variable V. V is any string " );
			System.out.println( "of letters, digits, and underscores that does not start with a digit." );
			System.out.println( ":= V:Push the value last stored in variable V on the stack." );
			System.out.println( "dup/d:Push a copy of the top of the stack to the stack." );
			System.out.println( "exch/x:Exchang the top two items on the stack." );
			System.out.println( "pop: Pop the top item of the stack." );
			System.out.println( "quit/q: Exit the program." );
			System.out.println( "?/help: Print a help message summarizing these commands." );
			System.out.println( "Look for more information in the user's handbook..." );
			break;
		case 19: 
			System.out.println( "Error: Invalid input! " );
		  break;
		default:
			throw new RuntimeException( "Error: Command Not Found! ");
		}
	}
  
  /**
	 * The main method for the class.
	 * It reads the input from the user. Parse it into tokens and
	 * choose the corresponding mathod to solve the problem.
	 *
	 * @exception  Throws input/output exception.
	 */
	public static void main( String[] args ) throws java.io.IOException
	{
		/** Read the input from the user.*/
		BufferedReader bufferedReader = 
			new BufferedReader( new java.io.InputStreamReader( System.in ) );

		/** Parse it by the class streamTokenizer.*/
		StreamTokenizer st;

		/** Parse it by the class stringTokenizer.*/
		StringTokenizer stringTokenizer;

    /** The object of the class Mcalc.*/
		Mcalc myMcalc = new Mcalc();    
		
		System.out.println( "Mcalc, version 1.0" );
		System.out.println( "Author: Rachel Chen 0122070" );
		
		while( true )
		{
			try
			{
				System.out.print( "> " );

				//統一轉換為小寫。
				String readLine = bufferedReader.readLine().toLowerCase();

				//使用下面的'\\'替換'/',以避免無法識別的問題。
				readLine = readLine.replace('/', '\\');
				readLine = readLine.replace('/', '\\');
				readLine = readLine.replaceAll( "=:", "save" );
				readLine = readLine.replaceAll( ":=", "load" );

				StringReader readExpression =	new StringReader( readLine );				
				st = new StreamTokenizer( readExpression );				
				int nextToken = st.nextToken();
        
				//Count the total number of the tokens.
				stringTokenizer = new StringTokenizer( readLine );
				int count = stringTokenizer.countTokens();	

        
				loop:
				{
					//依次選擇對應的命令,執行相關函數。
					for ( int i = 0; i < count; i++)
					{			
						switch( nextToken )
						{
							case StreamTokenizer.TT_NUMBER:
								myMcalc.readCommand(0, st.nval, null);
								break;
							case StreamTokenizer.TT_WORD:
								String cStr0 = "" + st.sval; 
								if (cStr0.equals("id"))
								{
									st.nextToken();
									i++;
									myMcalc.readCommand(3, st.nval, "id " + (int)st.nval);						
								}
								else if (cStr0.equals("t"))
								{
									myMcalc.readCommand(10, 0.0, "t");
								}
								else if (cStr0.equals("inv"))
								{
									myMcalc.readCommand(11, 0.0, "inv");
								}
								else if (cStr0.equals("save"))
								{								
									int test = st.nextToken();
									if ( test != StreamTokenizer.TT_WORD && st.ttype != 95 )
									{
										System.out.println( 
											"Error: The variable's name is invalid!" );
									}
									else
									{
										if ( st.ttype == 95 )  //95 stands for '_'
										{
											st.nextToken();
											i++;
											myMcalc.readCommand(12, 0.0, "_" + st.sval);
										}
										else
										{
											i++;
											myMcalc.readCommand(12, 0.0, st.sval);
										}
									}
								}
								else if (cStr0.equals("load"))
								{
									int test = st.nextToken();
									if ( test != StreamTokenizer.TT_WORD && st.ttype != 95 )
									{
										System.out.println( 
											"Error: The variable's name is invalid!" );
									}
									else
									{
										if ( st.ttype == 95 )
										{
											st.nextToken();
											i++;
											myMcalc.readCommand(13, 0.0, "_" + st.sval);
										}
										else
										{
											i++;
											myMcalc.readCommand(13, 0.0, st.sval);
										}
									}								
								}
								else if (cStr0.equals("d") || cStr0.equals("dup"))
								{
									myMcalc.readCommand(14, 0.0, "dup");
								}
								else if (cStr0.equals("x") || cStr0.equals("exch"))
								{
									myMcalc.readCommand(15, 0.0, "exch");
								}
								else if (cStr0.equals("pop"))
								{
									myMcalc.readCommand(16, 0.0, "pop");
								}
								else if (cStr0.equals("help"))
								{
									myMcalc.readCommand(18, 0.0, "help");
								}
								else if (cStr0.equals("q") || cStr0.equals("quit"))
								{
									myMcalc.readCommand(17, 0.0, "quit");
								}
								else
								{
									myMcalc.readCommand(19, 0.0, null);
								}
								break;
							default:
								char char0 = (char)st.ttype;
								String cStr = "" + char0; 

								if (cStr.equals("["))
								{
									myMcalc.readCommand(1, 0.0, "[");
								}
								else if (cStr.equals("]"))
								{
									myMcalc.readCommand(2, 0.0, "]");
								}						
								else if (cStr.equals("="))
								{							
									myMcalc.readCommand(4, 0.0, "=");
								}
								else if (cStr.equals("+"))
								{
									myMcalc.readCommand(5, 0.0, "+");
								}
								else if (cStr.equals("-"))
								{
									myMcalc.readCommand(6, 0.0, "-");
								}
								else if (cStr.equals("\\"))
								{
									myMcalc.readCommand(7, 0.0, "/");								
								}
								else if (cStr.equals("*"))
								{
									myMcalc.readCommand(8, 0.0, "*");
								}
								else if (cStr.equals("_"))
								{
									myMcalc.readCommand(9, 0.0, "_");
								}									
								else if (cStr.equals("?"))
								{
									myMcalc.readCommand(18, 0.0, "help");
								}
								else if (cStr.indexOf('#') == 0)
								{
									//對以后的所有字符不作處理。
									break loop;								
								}
								else
								{
									myMcalc.readCommand(19, 0.0, null);
								}
								break;				  
						 }
						nextToken = st.nextToken();
					}
				}
			}
			catch ( Exception e )
			{
				System.out.println("ERROR: " + e.getLocalizedMessage());
			}
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人av在线播放网址| 色8久久人人97超碰香蕉987| 国产精品视频看| 欧美精品一卡两卡| 成人avav在线| 久久99国内精品| 亚洲精品中文在线影院| 国产亚洲午夜高清国产拍精品 | 蜜臀国产一区二区三区在线播放| 国产亚洲一区二区在线观看| 欧美日韩国产不卡| 91欧美一区二区| 国产福利一区在线| 久久精品国产免费看久久精品| 亚洲日本在线视频观看| 国产日韩欧美高清| 精品伦理精品一区| 51久久夜色精品国产麻豆| 一本到不卡免费一区二区| 国产成人午夜高潮毛片| 久久99精品国产91久久来源| 婷婷六月综合亚洲| 成人在线视频一区| 日本伊人色综合网| 亚洲第一福利一区| 亚洲欧美另类久久久精品2019| 国产亚洲欧美日韩在线一区| 日韩欧美aaaaaa| 欧美一区二区在线免费观看| 欧美视频在线观看一区二区| 色综合一区二区| 99精品视频在线播放观看| 国产精品18久久久久久久网站| 日韩av高清在线观看| 天天做天天摸天天爽国产一区| 亚洲宅男天堂在线观看无病毒| 亚洲欧洲另类国产综合| 国产精品久久久久久久久动漫 | 亚洲国产成人va在线观看天堂| 亚洲日本中文字幕区| 亚洲视频一区二区在线| 日本一二三四高清不卡| 亚洲国产成人自拍| 国产精品免费视频观看| 国产精品嫩草99a| 国产精品久久久一区麻豆最新章节| 久久久噜噜噜久噜久久综合| 久久精品视频在线看| 国产午夜精品久久久久久久| 国产日韩三级在线| 中文字幕免费不卡| 日韩码欧中文字| 一区二区视频在线看| 亚洲国产美国国产综合一区二区| 波多野结衣亚洲| 波多野结衣中文一区| 91色|porny| 欧美日韩另类一区| 日韩欧美成人一区| 久久久久久久久久久久久夜| 欧美激情一区不卡| 亚洲男女一区二区三区| 午夜精品爽啪视频| 九色|91porny| 成人app网站| 欧美亚洲一区二区在线| 欧美一区二区三区成人| 久久精品亚洲国产奇米99| 国产精品国产三级国产普通话蜜臀| 亚洲精选视频在线| 日本中文一区二区三区| 国产精品中文有码| 色婷婷狠狠综合| 日韩欧美激情在线| 国产精品毛片久久久久久| 亚洲综合激情另类小说区| 美女在线观看视频一区二区| 国产精品一区二区在线看| 97成人超碰视| 日韩丝袜美女视频| 中文字幕在线视频一区| 日韩国产成人精品| 国产成人av在线影院| 欧美日韩一区二区三区高清| 精品国产网站在线观看| 自拍视频在线观看一区二区| 奇米色一区二区三区四区| 国产成人久久精品77777最新版本| 91麻豆国产自产在线观看| 日韩亚洲欧美一区| 亚洲三级在线免费| 久久精品国产在热久久| 日本韩国精品在线| 久久先锋影音av鲁色资源网| 亚洲永久精品大片| 国产成人午夜精品5599| 在线电影院国产精品| 中文字幕永久在线不卡| 日本va欧美va瓶| 色综合久久综合中文综合网| 精品久久久久久久久久久久久久久久久| 18欧美亚洲精品| 国产寡妇亲子伦一区二区| 69久久夜色精品国产69蝌蚪网| 国产精品久久久久久久久免费相片| 日本色综合中文字幕| 色综合久久99| 欧美激情综合在线| 激情六月婷婷久久| 91精品国产乱码| 亚洲国产日韩一区二区| 本田岬高潮一区二区三区| 久久综合色综合88| 三级亚洲高清视频| 色88888久久久久久影院野外| 欧美国产激情二区三区| 精品系列免费在线观看| 欧美一区二区视频在线观看| 一区二区三区四区五区视频在线观看 | 欧美一区二区三区色| 亚洲综合色网站| 91丨九色丨蝌蚪丨老版| 欧美精彩视频一区二区三区| 蜜桃av噜噜一区| 91精品黄色片免费大全| 午夜av一区二区| 欧美日韩三级一区| 亚洲午夜久久久久久久久电影网| 波多野洁衣一区| 日韩久久一区二区| 91在线视频免费观看| 国产精品久久久久一区二区三区共 | 亚洲欧美一区二区在线观看| 风间由美一区二区三区在线观看 | 亚洲国产日产av| 欧美探花视频资源| 亚洲午夜电影在线观看| 欧美一区二区三区啪啪| 国产亚洲精品久| 国产精品自拍网站| 国产日韩欧美精品在线| 国产福利一区二区三区视频| 久久久久九九视频| 成人综合在线观看| 亚洲少妇30p| 欧美最新大片在线看| 亚洲成人黄色影院| 欧美精品第1页| 久久国产精品色婷婷| 久久久久国色av免费看影院| 成人福利视频在线看| 亚洲特级片在线| 一本一本大道香蕉久在线精品 | 日韩国产欧美在线视频| 欧美一级片免费看| 韩国v欧美v亚洲v日本v| 欧美高清在线一区| 一本色道久久综合狠狠躁的推荐| 亚洲一区二区视频在线观看| 91精品国产全国免费观看| 加勒比av一区二区| 国产精品麻豆久久久| 色94色欧美sute亚洲13| 91一区一区三区| 午夜精品国产更新| 久久综合色婷婷| 9久草视频在线视频精品| 亚洲国产成人高清精品| 欧美mv日韩mv国产| 99精品视频在线免费观看| 午夜精品在线视频一区| 久久久久久久久久久99999| 91在线观看一区二区| 石原莉奈在线亚洲二区| 久久精品一区二区三区不卡 | 成人av在线影院| 亚洲电影第三页| 国产欧美日韩卡一| 欧美日韩在线播放| 国产盗摄精品一区二区三区在线 | 亚洲欧洲av在线| 欧美丰满嫩嫩电影| 成人午夜电影小说| 亚洲va欧美va人人爽| 国产亚洲精品bt天堂精选| 欧美在线不卡视频| 国产精品一区二区三区网站| 亚洲综合久久久| 国产欧美日韩麻豆91| 欧美老年两性高潮| 99久久伊人网影院| 理论片日本一区| 亚洲精品视频在线看| 久久中文娱乐网| 欧美主播一区二区三区| 成人黄色软件下载| 精品亚洲国内自在自线福利| 一区二区三区欧美日韩| 国产欧美日韩不卡免费| 91精品国产综合久久久久|