Scrieti un program care afiseaza numarul de aparitii a unei cifre x intr-un numar n;de ex daca citim n=2232 si x=2 se afiseaza numarul 3.
#include <iostream>
using namespace std;
int main()
{
int n,n1,nr,x;
cout<<“n=”;cin>>n;
cout<<“x=”;cin>>x;
nr=0;
n1=n;
do
{
if(n1%10==x) nr++;
n1=n1/10;
}while(n1);
cout<<“cifra “<<x<<” apare de “<<nr<<” ori”;
return 0;
}