Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package xor;
- import java.util.ArrayList;
- /**
- *
- * @author kamil
- */
- public class Xor {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String pom = new String("1100110011001110101011001111111000101101001000001010011101000110100110010011011110001000111111011101111001100011101000000000111011100101010100010111100110000111");
- String pod = new String("0011001001010110111100111011000011100000010111001011101100011000000101110001001011100110110111100111001100001101110100011111010000000001000010000001110100000101");
- ArrayList<Boolean> boolpom = new ArrayList<>();
- ArrayList<Boolean> boolpom2 = new ArrayList<>();
- uzuptabele(boolpom, pom);
- uzuptabele(boolpom2, pod);
- double ilosc_znakow = pom.length();
- double roznica = 0;
- for (int i = 0; i < boolpom.size(); i++) {
- if(boolpom.get(i)^boolpom2.get(i)==true){
- roznica++;
- }
- }
- System.out.println("Roznica: "+(int)roznica+" znakow");
- System.out.println("Roznica %: "+(roznica/ilosc_znakow*100));
- }
- public static void uzuptabele(ArrayList<Boolean> lista, String pom) {
- for (char c : pom.toCharArray()) {
- switch (c) {
- case '0':
- lista.add(Boolean.FALSE);
- break;
- case '1':
- lista.add(Boolean.TRUE);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement