Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pt4.h"
- #include <bits/stdc++.h>
- using namespace std;
- void Solve()
- {
- Task("Five8");
- string FN1,FN2,s;
- pt>>FN1>>FN2;
- ifstream filei (FN1);
- ofstream fileo (FN2);
- while(filei>>s)
- {
- string s1,s2,s3;
- if(s.find("+") != -1)
- {
- s1 = s.substr(0, s.find("+"));
- s2 = s.substr(s.find("+")+1, s.find("=")-s1.size()-1);
- s3 = s.substr(s.find("=")+1, s.size()-s2.size());
- if(strtol(s1.c_str() , 0, 2 )+ strtol(s2.c_str() , 0, 2 ) != strtol(s3.c_str() , 0, 2 )){
- fileo<<s+" -"<<endl;
- }else{
- fileo<<s<<endl;
- }
- }
- else
- {
- s1 = s.substr(0, s.find("*"));
- s2 = s.substr(s.find("*")+1, s.find("=")-s1.size()-1);
- s3 = s.substr(s.find("=")+1, s.size()-s2.size());
- if(strtol(s1.c_str() , 0, 2 ) * strtol(s2.c_str() , 0, 2 ) != strtol(s3.c_str() , 0, 2 )){
- fileo<<s+" -"<<endl;
- }else{
- fileo<<s<<endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement