426 - Fifth Bank of Swamp County
Solution Description : Ad hoc problem In this problem you do not need to sort the check number. You need to use 2 arrays,string date[10000], double amount[10000], boolean isGiven[10000] Example: If Input 93/10/15 1001 116.81 93/10/27 1000 840.85 93/10/28 1003 555.55 At first set all value of isGiven array false. For 93/10/15 1001 116.81, set isGiven[1001]=true, amount[1001]=116.81, date[1001]=93/10/15 For 93/10/27 1000 840.85, set isGiven[1000]=true, amount[1000]=840.85, date[1000]=93/10/27 For 93/10/28 1003 555.55, set isGiven[1003]=true, amount[1003]=555.55, date[1003]=93/10/28 Now check isGiven[i] from i=1 to 9999 if isGiven[i]==true then store check_no[j]=i, sort_amount[j]=amount[i], and sort_date[j]=date[i]. (For this input j=0 to 2) After that you need to print formatted output the arrays, check_no[], sort_amount[], and sort_date[]. Out-of-sequence check number: After sorting check_no[0]=1000, check_no[1]=1001, check_no[2]=1003 dif = check_no[i] - check_no[i-1]; if dif>1 then check_no[i] is a out of sequence check number. In this example 1003 is a out-of-sequence check number. because (1003 - 1001)=2 which is greater than 1. In this problem you need to check some nasty input. 93/10/15 100193/10/27 1000 9999999.99 93/10/28 1002 555.555 For check number 1001 you need to set the amount = 0.00 93/10/15 1001 15045.00 93/10/27 1000 840.85 93/10/28 1003 15045.00 93/10/29 1006 For check number 1006 you need to set the amount = 15045.00 (Previous one amount) |
||||||||||