Advertisement
Guest User

2019 PR 4.1

a guest
Feb 22nd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. bool czyPotega(int tab[], long liczba){
  8.     for(int i=0; i<13; i++){
  9.         if(liczba==tab[i]){
  10.             return 1;
  11.         }
  12.     }
  13.     return 0;
  14.  
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.     int tab[13];
  21.     for(int i=0; i<13; i++){
  22.         tab[i]=pow(3,i);
  23.     }
  24.  
  25.  
  26.     int licznik=0;
  27.     fstream plik;
  28.     long long linia;
  29.     plik.open("liczby.txt");
  30.  
  31.     while(!plik.eof()){
  32.         plik>>linia;
  33.         if(czyPotega(tab, linia)==true){
  34.             licznik++;
  35.         }
  36.     }
  37.     cout<<licznik;
  38.     plik.close();
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement