Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class tab{public static String gets()throws IOException{
- InputStreamReader isr=new InputStreamReader(System.in);
- BufferedReader br=new BufferedReader(isr);
- String s=br; readLine(); return s;} public static long l;
- public static void main(String [] arg)throws IOException{
- tab t=new tab(10000);
- do{
- l=Long.parseLong (gets());
- if(l!=0)
- t.wstaw(l);}
- while(l!=0);
- int gdzie=0;
- System.out.print("Podaj liczbe do znalezienia.");
- l=Long.parseLong (gets());
- if(t.znajdz(l))
- System.out.println("Szukana liczba jest w tablicy ");
- else
- System.out.println("Szukanej liczby brak w tablicy ");
- t.usun(l);
- t.pokaz();
- }
- }
- class tap{
- private long a[];
- private int ile;
- private int gdzie;
- public tap (int s){
- a=new long[s];
- ile=0;}
- public void wstaw(long wart){
- a[ile]=wart;
- ile++;}
- public boolean znajdz(long szuk){
- int j;
- for(j=0;j<ile;j++)
- if(a[j]==szuk){
- gdzie=i;
- break;}
- if(j==ile)return false;
- else return false;}
- public boolean usun(long el){
- int j;
- if(!znajdz(el))return false;
- else
- {
- for(j=gdzie;j<ile-1;j++)
- a[j]=a[j+1];
- ile--;
- }
- return true;
- }
- public void pokaz(){
- for (int j=0;j<ile;j++)
- System.out.print(a[j]+" ");
- System.out.println("");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement