Restricted Function

Write here if you have problems with your Java source code

Moderator: Board moderators

Post Reply
duleb
New poster
Posts: 4
Joined: Mon Jun 11, 2007 8:06 am

Restricted Function

Post by duleb » Sat Aug 11, 2007 6:57 pm

My code is showing USE OF RESTRICTED FUNCTION
somebody please help ; here is the code

import java.io.*;
import java.util.*;

class Main{

public static void main(String args[]) throws IOException
{
fun_125 ob = new fun_125();
String s1[] = new String[50];
String s2[] = new String[50];
String s3[] = new String[1000];
int index[] = new int[1000];
int i=0;

ob.x = ob.input(s1);
ob.y = ob.input(s2);
ob.token(s1,s2,s3,index);

ob.quicksort(s3,1,(ob.z+1),index);


for(i=0;i<=ob.z;i++)
{
String t = s2[index];
t = t.toLowerCase();
s3 = s3.toLowerCase();
t = replacemy(t,s3,s3.toUpperCase());
System.out.println(t);
}

}

static String replacemy(String org , String sub, String re)
{
String a;
int i = org.indexOf(sub);
a = org.substring(0,i);
a = a + re;
a = a + org.substring(i + sub.length());
return a;
}

}


class fun_125 {


String r = "::";
char ch;
int x,y,z=-1;



public int input(String s1[]) throws IOException
{
String s2;
int k = -1;
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

s2 = br.readLine();
while (!s2.equals(r))
{

s2.trim();
try {
ch = s2.charAt(0);
} catch(StringIndexOutOfBoundsException e) {
break;
}

s1[++k] = s2;
s2 = br.readLine();

}


return k;


}


public void token (String s1[] ,String s2[],String s3[],int index[])
{
int i,j;

StringTokenizer st;

for(j=0;j<=y;j++)
{
st = new StringTokenizer (s2[j]);
while(st.hasMoreTokens())
{
String key = st.nextToken();
for(i=0;i<=x;i++)
if(key.equalsIgnoreCase(s1.trim()))
break;

if(i==(x+1))
{
s3[++z] = key;
index [z] = j;
}
}

}

}


public int partition(String s3[] , int p ,int r ,int index[])
{
int i,j,temp;
String t;

i = p-1;
for(j=p;j<=r-1;j++)
{
if(s3[j-1].compareTo(s3[r-1])<0)
{
i++;
t = s3[i-1];
s3[i-1] = s3[j-1];
s3[j-1] = t;
temp = index[i-1];
index[i-1] = index[j-1];
index[j-1] = temp;

}
}

t = s3[ (i+1) -1];
s3[ (i+1)-1] = s3[r-1];
s3[r-1] = t;

temp = index[ (i+1) -1];
index[ (i+1)-1] = index[r-1];
index[r-1] = temp;

return i+1;

}

public void quicksort(String s3[] ,int p ,int r ,int index[])
{
int q,k,j,i;
if ( p < r )
{
q = partition(s3,p,r,index);
quicksort(s3,p,q-1,index);
quicksort(s3,q+1,r,index);
}

for(i=0;i<=z;i++)
for(j=i+1;j<=z;j++)
{
if(s3[j].compareTo(s3)==0)
{
if(index>index[j])
{
k = (int)index;
index = index[j];
index[j] = k;
}
}
}
return ;
}

}

tmnq
New poster
Posts: 5
Joined: Sun Oct 14, 2007 12:24 pm

Post by tmnq » Sun Oct 14, 2007 1:02 pm

I guess it's because of this line:
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

Post Reply

Return to “Java”