Advertisement
Guest User

podzielnosc5

a guest
Nov 22nd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. using namespace std;
  7.  
  8. bool podzielnosc (int liczba){
  9.     int suma=0;
  10.     while (liczba>0){
  11.         suma=liczba%10;
  12.         if (suma==0 || suma==5) return true;
  13.         return false;
  14.     }
  15. }
  16. int main(int argc, char *argv[])
  17. {
  18.         fstream dane, wynik;
  19.         dane.open ("dane.txt", ios::in);
  20.         wynik.open ("wynik.txt", ios::out);
  21.        
  22.         int n;
  23.         while (!dane.eof()){
  24.         dane>>n;
  25.         if (podzielnosc(n)==true)wynik<<n<<endl;
  26.         }
  27.    
  28.     dane.close ();
  29.     wynik.close();
  30.        
  31.     system ("PAUSE");
  32.     return EXIT_SUCCESS;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement