Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int wystapienia(int liczba, int cyfra)
- {
- int suma=0;
- do
- {
- if(liczba%10==cyfra)
- {
- suma++;
- }
- liczba = liczba/10;
- }
- while(liczba!=0);
- return suma;
- }
- int main()
- {
- int liczba,cyfra;
- cout << "Podaj liczbe: " << endl;
- cin >> liczba;
- cout << "Podaj cyfre: " << endl;
- cin >> cyfra;
- cout << "Cyfra " << cyfra << " wystepuje w liczbie "<<liczba<<", "<<wystapienia(liczba,cyfra)<<" raz/y.";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement