Results 1 to 9 of 9
Thread: Runtime Error
- 09-17-2010, 07:43 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Runtime Error
Hi there ,im new with java, i write a code which working fine in my machine but when i submit to UVA web it produce runtime error,could anyone help me identify what is the cause of that problem
.It does not show any specific error for me to look into, it just say that my program didnt finish properly.
here is my code
Java Code:import java.util.*; import java.util.Arrays; class BruteForces { public static int totalsum=0; public static String outputAll1=""; public static String outputAll2=""; public static void main(String[] args) { //iniatialize array; Scanner in = new Scanner(System.in);//use system.in to read input int Intdatacase=0; String datacase=""; //get data case try { datacase = in.next(); Intdatacase=Integer.parseInt(datacase); } catch ( Exception e) { System.exit(0); } if ( datacase == null ) System.exit(0); int intLoop=0,IntInputsz=0; String InputDatas=""; if(Intdatacase>15||Intdatacase<1)System.exit(0); for(intLoop=0;intLoop<Intdatacase;intLoop++){ outputAll1=""; outputAll2=""; String[] InputDatasLoopAr1; String[] InputDatasLoopAr2; String InputDatasLoopA="",InputDatasLoopA2=""; //get input for each case InputDatas=""; //get how many words in a cases try { IntInputsz = in.nextInt(); } catch ( Exception e) { break; } //enter first words if(IntInputsz>0&&IntInputsz<=100){ try{ InputDatas = in.next(); InputDatas=InputDatas.toLowerCase().trim(); if(InputDatas.length()>100)break; } catch ( Exception e) { break; } if ( InputDatas == null ) break; } else break; for(int i=0;i<IntInputsz-1;i++) { String InputDatasLoop=""; //get next word if size word >1 try { InputDatasLoop = in.next(); InputDatasLoop=InputDatasLoop.toLowerCase().trim(); if(InputDatasLoop.length()>100)break; } catch ( Exception e) { break; } if ( InputDatasLoop == null ) {break;} if(InputDatasLoop.charAt(0)==InputDatas.charAt(0)) { InputDatasLoopA=InputDatasLoopA+InputDatasLoop.toLowerCase()+" "; } else InputDatasLoopA2=InputDatasLoopA2+InputDatasLoop.toLowerCase()+" "; } InputDatasLoopAr1=InputDatasLoopA.split(" "); InputDatasLoopAr2=InputDatasLoopA2.split(" "); Arrays.sort(InputDatasLoopAr1); Arrays.sort(InputDatasLoopAr2); totalsum=InputDatas.length();//get first value of word outputAll1=InputDatas;//insert first word if(InputDatasLoopA.length()>1) calculate(InputDatasLoopAr1,InputDatas,"A",totalsum);//calculate for first array InputDatas="";//clear inputdatas if(InputDatasLoopA2.length()>1) calculate(InputDatasLoopAr2,InputDatas,"D",totalsum);//calculate for second array System.out.printf(totalsum+"\n"+outputAll1+"\n"+outputAll2);//display output //intLoop++; } System.exit(0); } public static void calculate(String[] strArray,String InputDatas,String Arrange,int total) { int LastIndex=InputDatas.length(),CountNext=0; int InputDatasB=0,Loops=0; for(int iz=0;iz<strArray.length;) { if((InputDatasB==1&&!strArray[iz].equals("-"))||(InputDatas.equals("")&&!strArray[iz].equals("-"))) { InputDatas=strArray[iz]; LastIndex=strArray[iz].length(); InputDatasB=0; totalsum+=LastIndex; } if(!strArray[iz].equals("-")){ int pos2 = strArray[iz].indexOf(InputDatas.substring(0, LastIndex)); if(pos2==0) { if(Arrange.equals("D")) outputAll2=strArray[iz]+"\n"+outputAll2; else outputAll1=outputAll1+"\n"+strArray[iz]; totalsum+=(strArray[iz].length()-LastIndex); InputDatas=strArray[iz]; LastIndex=strArray[iz].length(); strArray[iz]="-"; Arrays.sort(strArray); } } iz++; // CountNext=iz+1; if(iz==strArray.length) { iz=0; LastIndex--; } if(LastIndex==0) { InputDatasB=1; } if(strArray[strArray.length-1].equals("-")){ // Loops=1; break; } } return; } }
- 09-17-2010, 08:04 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 09-17-2010, 08:08 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
a
As i said before , it only said runtime error, but i did receive an email said that it might be my program didnt finish properly.
- 09-17-2010, 08:10 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 09-17-2010, 08:11 PM #5
Sounds bad. A program that doesn't finish properly should be sent out for repair.it might be my program didnt finish properly.
Can you get any more information than that?
Can you add some comments to the code describing what it is supposed to do?
- 09-17-2010, 08:14 PM #6
Cross posted at Runtime Error running in UVA - Java Programming Forums
- 09-17-2010, 08:21 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
I already posted in UVA forum, but still no answer, i already spend two days for this thing. but still unable to solve it. so i got no ideas what is really going on with my code.as far as i know it perfectly run using my machine
- 09-17-2010, 08:22 PM #8
Can you add some comments to the code describing what it is supposed to do?
- 09-17-2010, 08:26 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
RunTime Error
By LostinJavaLand in forum New To JavaReplies: 3Last Post: 07-12-2010, 01:30 PM -
runtime error problems. please help!
By RoadRunner in forum Forum LobbyReplies: 0Last Post: 04-21-2009, 05:03 PM -
I can't fix this runtime error in my program
By Sinnergy in forum New To JavaReplies: 5Last Post: 02-25-2009, 04:29 PM -
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 08:53 AM -
Weblogic 5.0 runtime error with EJB 1.0
By somesh in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 08-25-2008, 03:09 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks