Professional Documents
Culture Documents
Статичко рутирање
Статичко рутирање
.
.
,
, ,
(postoi
nepostoi). /24,
8 .
, ,
, .
10.10.10.0,
(10.10.10.1- 10.10.10.254).
, IP ,
IP .
.
IP
.
:RoutingHashJava
Sample input
2
23.3.3.3
10.10.10.0
192.168.1.1
20.2.2.0
2
192.168.1.1
20.2.2.1
13.13.3.3
192.2.2.2
Sample output
postoi
ne postoi
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
@Override
public String toString() {
return element.toString();
}
}
class CBHT<K extends Comparable<K>, E> {
@SuppressWarnings("unchecked")
public CBHT(int m) {
// Construct an empty CBHT with m buckets.
buckets = (SLLNode<MapEntry<K,E>>[]) new SLLNode[m];
}
public void insert(K key, E val) { // Insert the entry <key, val> into
this CBHT.
MapEntry<K, E> newEntry = new MapEntry<K, E>(key, val);
int b = hash(key);
for (SLLNode<MapEntry<K,E>> curr = buckets[b]; curr != null; curr =
curr.succ) {
if (key.equals(((MapEntry<K, E>) curr.element).key)) {
// Make newEntry replace the existing entry ...
curr.element = newEntry;
return;
}
}
// Insert newEntry at the front of the 1WLL in bucket b ...
buckets[b] = new SLLNode<MapEntry<K,E>>(newEntry, buckets[b]);
}
int N = Integer.parseInt(input.readLine());
CBHT<String,String> tabela = new CBHT<>(N/2+1);
for(int i=0;i<N;i++)
{
String ruter = input.readLine();
String mreza = input.readLine();
tabela.insert(ruter, mreza);
}
int M = Integer.parseInt(input.readLine());
for(int i=0;i<M;i++)
{
String ruter = input.readLine();
SLLNode<MapEntry<String,String>> eli = tabela.search(ruter);
String mreza = input.readLine();
if(eli!=null)
{
String m[] = mreza.split("\\.");
String e[] = eli.element.value.split("\\.");
}
else
{
System.out.println("ne postoi");
}
}
else
{
System.out.println("ne postoi");
}
}
}