5 Replies - 500 Views - Last Post: 02 July 2015 - 08:26 AM Rate Topic: -----

#1 wanmoxi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-July 15

New in programming--Getting runtime error(NZEC)--working fine eclipse

Posted 02 July 2015 - 07:03 AM

package Spoj;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;

public class ReversePostfixNotation {




	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int testcase = Integer.parseInt(br.readLine());
		while(testcase>0){
			String t=br.readLine();
		char[] st=t.toCharArray();
		String res="";
		Stack<Character> stack=new Stack<Character>();
		int i;
		for( i=0;i<st.length;i++)
		{
			if(st[i]=='(')
			{
				continue;
			}
			 if((st[i]>='a')&&(st[i]<='z'))
			{
				res=res+st[i];
			}
		    if(st[i]=='+' || st[i]=='*' ||st[i]=='-'||st[i]=='^')
		  {
			  stack.push(st[i]);
		  }	
		  else if(st[i]==')')
		  { 
			  res=res+stack.pop();
			
			 }
			 
		  }
		System.out.println(res);
		
		}	
		
	}	
}


please help why i am getting runtime error while running in SPOJ

This post has been edited by ChrisNt: 02 July 2015 - 07:07 AM
Reason for edit:: code tags


Is This A Good Question/Topic? 0
  • +

Replies To: New in programming--Getting runtime error(NZEC)--working fine eclipse

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 14036
  • View blog
  • Posts: 56,155
  • Joined: 12-June 08

Re: New in programming--Getting runtime error(NZEC)--working fine eclipse

Posted 02 July 2015 - 07:15 AM

Please copy/paste the error text here.
Was This Post Helpful? 0
  • +
  • -

#3 wanmoxi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-July 15

Re: New in programming--Getting runtime error(NZEC)--working fine eclipse

Posted 02 July 2015 - 07:18 AM

ID DATE USER PROBLEM RESULT TIME MEM LANG
14586727 2015-07-02 16:17:26 kundanfast Transform the Expression runtime error (NZEC)
edit ideone it
0.06 1340M JAVA


problem name--- ONP - Transform the Expression

Input:
3
(a+(b*c))
((a+B)*(z+x))
((a+t)*((b+(a+c))^(c+d)))

Output:
abc*+
ab+zx+*
at+bac++cd+^*
Was This Post Helpful? 0
  • +
  • -

#4 wanmoxi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-July 15

Re: New in programming--Getting runtime error(NZEC)--working fine eclipse

Posted 02 July 2015 - 08:22 AM

Please help
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 14036
  • View blog
  • Posts: 56,155
  • Joined: 12-June 08

Re: New in programming--Getting runtime error(NZEC)--working fine eclipse

Posted 02 July 2015 - 08:26 AM

Please remember this is a volunteer forum and folks are free to post and comment as they see fit. Also try to avoid excessively bumping your thread when it was only updated less than an hour ago.
Was This Post Helpful? 0
  • +
  • -

#6 xclite  Icon User is offline

  • I wrote you an code
  • member icon


Reputation: 1280
  • View blog
  • Posts: 4,086
  • Joined: 12-May 09

Re: New in programming--Getting runtime error(NZEC)--working fine eclipse

Posted 02 July 2015 - 08:26 AM

No need to bump. People will help you if and when they can.

Did you post the error? Do you expect us to guess what the error is?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1