1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
|
#include <iostream>
using namespace std;
int main(){
unsigned long long Zahl, Ziffer1, Ziffer;
int counter = 0;
cout << "Geben sie eine Zahl ein die untersucht werden soll: ";
cin >> Zahl;
cout << "Geben sie eine Ziffer ein: ";
cin >> Ziffer;
for (Ziffer1 = 0; Zahl > 0; Zahl /= 10)
{
Ziffer1 = Zahl % 10;
if (Ziffer1 == Ziffer) counter++;
}
if (counter == 0) cout << "Ziffer kommt nicht vor" << endl;
else cout << "Ziffer kommt " << counter << " mal vor" << endl;
} |