EΡΠ»ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π°Π½Π½ΡΠ΅ ΠΈΠ· ΠΏΡΠΈΠΌΠ΅ΡΠ°, ΡΠΎ Π½Π°Ρ
ΠΎΠ΄ΠΈΡ Π½ΡΠΆΠ½ΡΠ΅ ΡΡΡΠΎΠΊΠΈ, Π½ΠΎ Π²Π°Π»ΠΈΠ΄Π°ΡΠΎΡ Π½Π΅ ΠΏΡΠΎΠΏΡΡΠΊΠ°Π΅Ρ.
package com.javarush.task.task19.task1922;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
ΠΡΠ΅ΠΌ Π½ΡΠΆΠ½ΡΠ΅ ΡΡΡΠΎΠΊΠΈ
*/
public class Solution {
public static List<String> words = new ArrayList<String>();
static {
words.add("ΡΠ°ΠΉΠ»");
words.add("Π²ΠΈΠ΄");
words.add("Π");
}
public static void main(String[] args) throws IOException {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
// String fileName = "C:\\test\\task1922.txt";
String fileName = console.readLine();
console.close();
BufferedReader file = new BufferedReader(new FileReader(fileName));
while (file.ready()){
String line = file.readLine();
// if(line.isEmpty()) continue;
int count = 0;
for (String w : words) {
Matcher m = Pattern.compile(w).matcher(line);
while (m.find()){
count++;
// System.out.println(count + " " + line);
}
}
if(count == 2){
// System.out.println("");
System.out.println(line);
}
}
file.close();
}
}