Académique Documents
Professionnel Documents
Culture Documents
//THE ALGORITHM HANGS FOR ZERO ANY INPUTS,SO FILTER OUT THE ZEROES IN THE MAIN LOOP
import java.io.*;
import java.util.*;
class SumHunt
{
public static int n=12,cnt=0,SUM=0;
public static int D1[]=new int[n];
String BL="",LL=""; //A summing list of positions
void BLCutLast()
{
while(true)
{
BL=BL.substring(1); //Cuts away the first character
if(BL.charAt(0)=='+') //Once you encounter the plus sign,delete that
too and stop
{
BL=BL.substring(1);
break;
}
}
}
void sortArray()
{
int i=0,j=0,t=0;
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(D1[j]>D1[j+1])
{
t=D1[j];
D1[j]=D1[j+1];
D1[j+1]=t;
}
}
}
}