Advertisement
PiotrSzewczyk

Zad 8

Mar 31st, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5. void podzielnosc(int dlugosc, int dzielnik)
  6. {
  7.     int a;
  8.     if(dlugosc==1){
  9.         a=0;
  10.     }
  11.     else{
  12.         a=pow(10, dlugosc-1);
  13.     }
  14.     int b=pow(10, dlugosc);
  15.     bool check=true;
  16.     int i=1;
  17.     while(check)
  18.     {
  19.         if(dzielnik*i>=a && dzielnik*i<b){
  20.             cout <<dzielnik*i<<endl;
  21.             i++;
  22.         }
  23.         if(dzielnik*i<a){
  24.             i++;
  25.         }
  26.         if(dzielnik*i>=b){
  27.             check=false;
  28.         }
  29.     }
  30. }
  31.  
  32. int main()
  33. {   //Czasami może wystąpić błąd kompilatora i nie wyświetlą się pewne liczby
  34.     int a, b;
  35.     cout<<"Podaj ilocyfrowe liczby Cie interesuja: ";
  36.     cin>>a;
  37.     cout<<"Podaj, przez co maja byc podzielne: ";
  38.     cin>>b;
  39.     cout<<"Twoje liczby to: "<<endl;
  40.     podzielnosc(a, b);
  41.     return(0);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement