Advertisement
maria_andrada_

Untitled

Jan 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include<windows.h>
  4. using namespace std;
  5. int n,s,ogl,c;
  6. int main()
  7. {
  8.     cin>>n;
  9.     do
  10.     {
  11.         system("cls");
  12.         cout<<"1.Palindrom"<<endl;
  13.         cout<<"2.Calculati numarul de cifre"<<endl;
  14.         cout<<"3.Afisati divizorii numarului"<<endl;
  15.         cout<<"4.Produsul cifrelor"<<endl;
  16.         cout<<"Alege:";
  17.         cin>>s;
  18.         switch(s)
  19.         {
  20.         case 1 :
  21.         {
  22.             system ( "cls");
  23.             cin>>n;
  24.             ogl=0;
  25.             c=n;
  26.             while(c>0)
  27.             {
  28.                 ogl=ogl*10 + c%10;
  29.                 c=c/10;
  30.             }
  31.             if(ogl==n)
  32.                 cout<<n<<"e palindrom";
  33.             else
  34.                 cout<<n<<"nu e palindrom";
  35.             break;
  36.  
  37.         }
  38.  
  39.  
  40.         case 2 :
  41.         {
  42.             system ("cls");
  43.             cin>>n;
  44.             int nr=0;
  45.             while(n>0)
  46.             {
  47.                 nr=nr+1;
  48.                 n=n/10;
  49.             }
  50.             cout<<"numarul de cifre="<<nr;
  51.             break;
  52.  
  53.         }
  54.  
  55.         case 3 :
  56.         {
  57.             system ("cls");
  58.             cin>>n;
  59.             for(int d=1; d<=n; d++)
  60.             {
  61.                 if(n%d==0)
  62.                     cout<<d;
  63.             }
  64.             break;
  65.         }
  66.  
  67.         case 4 :
  68.         {
  69.             system ( "cls");
  70.             cout<<"Produdul cifrelor imapre";
  71.             int z,p=1,ok=0;
  72.             cin>>n;
  73.             while(n>1)
  74.             {
  75.                 z=n%10;
  76.                 if(z%2==1)
  77.                 {
  78.                     p=p*z;
  79.                     ok=1;
  80.                 }
  81.             }
  82.             n=n/10;
  83.             if(ok==0)
  84.             {
  85.                 cout<<"nu exista cfre impare ";
  86.                 else
  87.                     cout<<p;
  88.             }
  89.             break;
  90.  
  91.         }
  92.  
  93.         case 4 :
  94.             {
  95.                 system ("cls")
  96.                 cout<<"Produsul cifrelor pare";
  97.                 p=1;
  98.                 ok=0;
  99.                 while(n>1)
  100.                 {
  101.                     z=n%10;
  102.                     if(z%2==0)
  103.                     {
  104.                         p=p*z;
  105.                         ok=1;
  106.                     }
  107.                 }
  108.                 n=n/10;
  109.                 if(ok==0)
  110.                 {
  111.                     cout<<"nu exista cifre pare";
  112.                     else
  113.                         cout<<p;
  114.                 }
  115.                 break;
  116.  
  117.                 }
  118.                 //default:cout<<"Eroare";
  119.             }
  120.             cout<<endl;
  121.             system ("pause");
  122.  
  123.           }while(s);
  124.           return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement