Advertisement
icatalin

1.Frecventa numere

Nov 25th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. //Acest program analizeaza cifrele unui numar si precizeaza frecventa numerelor.
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     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;
  9.     cout<< "Introduceti un numar format din maxim 9 cifre...";
  10.     cin>>n;
  11.     while (n!=0){
  12.         cif=n%10;
  13.         n=n/10;
  14.      if (cif==0)
  15.         zero=zero++;
  16.      if (cif==1)
  17.         unu=unu++;
  18.     if (cif==2)
  19.         doi=doi++;
  20.     if (cif==3)
  21.         trei=trei++;
  22.     if (cif==4)
  23.         patru=patru++;
  24.     if (cif==5)
  25.         cinci=cinci++;
  26.     if (cif==6)
  27.         sase=sase++;
  28.       if (cif==7)
  29.         sapte=sapte++;
  30.     if (cif==8)
  31.         opt=opt++;
  32.     if (cif==9)
  33.         noua=noua++;
  34.     }
  35.      cout<<"Cifre de zero..."<<zero<<endl;
  36.      cout<<"Cifre de unu..."<<unu<<endl;
  37.      cout<<"Cifre de doi..."<<doi<<endl;
  38.     cout<<"Cifre de trei..."<<trei<<endl;
  39.      cout<<"Cifre de patru..."<<patru<<endl;
  40.      cout<<"Cifre de cinci..."<<cinci<<endl;
  41.      cout<<"Cifre de sase..."<<sase<<endl;
  42.      cout<<"Cifre de sapte..."<<sapte<<endl;
  43.      cout<<"Cifre de opt..."<<opt<<endl;
  44.      cout<<"Cifre de noua..."<<noua<<endl;
  45.     return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement