Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <math.h>
- using namespace std;
- bool czy2(string a){
- int b=0,c=0,d=0,e;
- for(int i=a.length();i>0;i--){
- e=(int)a[i]-48;
- c=c+(e*pow(2,b));
- b++;
- }
- if(c%2==0) return true;
- else return false;
- }
- bool czy8(string a){
- int b=0,c=0,d=0,e;
- for(int i=a.length();i>0;i--){
- e=(int)a[i]-48;
- c=c+(e*pow(2,b));
- b++;
- }
- if(c%8==0) return true;
- else return false;
- }
- int main(){
- ifstream odczyt("liczby.txt");
- string a;
- int e=0,f=0;
- for(int i=0;i<1000;i++){
- odczyt>>a;
- if(czy2(a)==true) e++;
- if(czy8(a)==true) f++;
- }
- cout<<e<<endl<<f;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement