Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. /*void potegi(int x)
  6. {
  7.     int k[10];
  8.     k[0] = x;
  9.     for(int i = 1; i < 10; i++)
  10.         k[i] = x * k[i-1];
  11.         cout << k[5] << endl;
  12.  
  13.  
  14. }*/
  15.  
  16. int main()
  17. {
  18.     int k[10];
  19.     int t[500];
  20.     int x = 3;
  21.     int n = 0;
  22.     k[0] = x;
  23.     for(int i = 1; i < 10; i++)
  24.         k[i] = x * k[i-1];
  25.  
  26.     ifstream plik;
  27.     plik.open("liczby.txt");
  28.     for(int l = 0; l < 500; l++)
  29.         plik >> t[l];
  30.    while(n < 500)
  31.    {
  32.     if (t[n] == 1 || t[n] == k[0] || t[n] == k[1] || t[n] == k[2] || t[n] == k[3] || t[n] == k[4] || t[n] == k[5] || t[n] == k[6] || t[n] == k[7] || t[n] == k[8] || t[n] == k[9])
  33.     cout << t[n] << endl;
  34.    n++;
  35.    }
  36.  
  37.  
  38.  
  39.    /* if( plik.good() )
  40. {cout << "ok" << endl;
  41.     //INFO: plik udało się otworzyć
  42. } else
  43. {cout << "nie ok" << endl;
  44.     //INFO: otwarcie pliku się nie powiodło
  45. } //else
  46. */
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement