Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //obsloga strumienia I/O
- #include <cmath> //funkcje matematyczne
- #include <string>
- #include <fstream> //do plików
- #include <ctime> //czas
- #include <cstdlib>
- #include <iomanip> // do manipulacji strimeniem wyjscia
- using namespace std;
- int main(){
- fstream file("liczby.txt");
- int parzyste = 0;
- int maxD = 0;
- string maxS = "";
- int sl = 0;
- while(!file.eof()){
- string s;
- file >> s;
- if(s[s.length()-1] == '0')
- parzyste++;
- int n = 0;
- for(int i = s.length()-1, j = 0; i >= 0; i--, j++){
- n += pow(2, j) * (s[i]-'0');
- }
- if(maxD < n){
- maxD = n;
- maxS = s;
- }
- if(s.length() == 9){
- sl++;
- }
- }
- cout << "Najwieksza(10): " << maxD << " (2): " << maxS << endl;
- cout << parzyste << endl;
- cout << "Liczby majace 9 cyfr: " << sl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement