Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zpliku;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- public class Main {
- public static void main(String[] args) {
- parzyste();
- tylesamo();
- }
- public static void parzyste() {
- int count=0;
- int c = 0;
- int t=0;
- int j=0;
- try {
- Scanner input = new Scanner(System.in);
- File file = new File("plik.txt");
- input = new Scanner(file);
- while (input.hasNextLine()) {
- String line = input.nextLine();
- //System.out.println(line);
- if(line.length()%2==0) count++;
- }
- System.out.println(count);
- input.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void tylesamo(){
- int c = 0;
- int t=0;
- int j=0;
- try {
- Scanner input = new Scanner(System.in);
- File file = new File("plik.txt");
- input = new Scanner(file);
- while (input.hasNextLine()) {
- String line = input.nextLine();
- //System.out.println(line);
- for(int i=0; i<line.length(); i++){
- if (line.charAt(i) == '0') c++;
- if (line.charAt(i) == '1') j++;
- }
- if(c==j) t++;
- c=0; j=0;
- }
- System.out.println(t);
- input.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement