#include #include #include #include #include using namespace std; int main() { string line; ifstream myfile("Text.txt"); //byr iyr eye hgt hcl ecl pid cid /*byr(Birth Year) iyr(Issue Year) eyr(Expiration Year) hgt(Height) hcl(Hair Color) ecl(Eye Color) pid(Passport ID) cid(Country ID)*/ int valid = 0; int valid2 = 0; if (myfile.is_open()) { string passport; while (getline(myfile, line)) { passport += line + " "; if (line == "") { bool byr, iyr, eyr, hgt, hcl, ecl, pid; byr = iyr = eyr = hgt = hcl = ecl = pid = false; if (passport.find("byr:") != std::string::npos) { byr = true; } if (passport.find("iyr:") != std::string::npos) { iyr = true; } if (passport.find("eyr:") != std::string::npos) { eyr = true; } if (passport.find("hgt:") != std::string::npos) { hgt = true; } if (passport.find("hcl:") != std::string::npos) { hcl = true; } if (passport.find("ecl:") != std::string::npos) { ecl = true; } if (passport.find("pid:") != std::string::npos) { pid = true; } bool a, b; a = false; b = false; if (byr == iyr == eyr == hgt == hcl == ecl == pid == true) { valid++; a = true; } if (byr == true && iyr == true && eyr == true && hgt == true && hcl == true && ecl == true && pid == true) { valid2++; b=true; } if (a != b){ cout << (pid == true) << endl; cout << (ecl == pid == true) << endl; cout << (hcl == ecl == pid == true) << endl; cout << (hgt == hcl == ecl == pid == true) << endl; cout << (eyr == hgt == hcl == ecl == pid == true) << endl; cout << (iyr == eyr == hgt == hcl == ecl == pid == true) << endl; cout << (byr == iyr == eyr == hgt == hcl == ecl == pid == true) << endl; cout << passport; } passport = ""; } } } cout << valid; cout << valid2; myfile.close(); }