Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Acest program analizeaza cifrele unui numar si precizeaza frecventa numerelor.
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,cif,zero=0,unu=0,doi=0,trei=0,patru=0,cinci=0,sase=0,sapte=0,opt=0,noua=0,i=10;
- cout<< "Introduceti un numar format din maxim 9 cifre...";
- cin>>n;
- while (n!=0){
- cif=n%10;
- n=n/10;
- if (cif==0)
- zero=zero++;
- if (cif==1)
- unu=unu++;
- if (cif==2)
- doi=doi++;
- if (cif==3)
- trei=trei++;
- if (cif==4)
- patru=patru++;
- if (cif==5)
- cinci=cinci++;
- if (cif==6)
- sase=sase++;
- if (cif==7)
- sapte=sapte++;
- if (cif==8)
- opt=opt++;
- if (cif==9)
- noua=noua++;
- }
- cout<<"Cifre de zero..."<<zero<<endl;
- cout<<"Cifre de unu..."<<unu<<endl;
- cout<<"Cifre de doi..."<<doi<<endl;
- cout<<"Cifre de trei..."<<trei<<endl;
- cout<<"Cifre de patru..."<<patru<<endl;
- cout<<"Cifre de cinci..."<<cinci<<endl;
- cout<<"Cifre de sase..."<<sase<<endl;
- cout<<"Cifre de sapte..."<<sapte<<endl;
- cout<<"Cifre de opt..."<<opt<<endl;
- cout<<"Cifre de noua..."<<noua<<endl;
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement