Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<windows.h>
- using namespace std;
- int n,s,ogl,c;
- int main()
- {
- cin>>n;
- do
- {
- system("cls");
- cout<<"1.Palindrom"<<endl;
- cout<<"2.Calculati numarul de cifre"<<endl;
- cout<<"3.Afisati divizorii numarului"<<endl;
- cout<<"4.Produsul cifrelor"<<endl;
- cout<<"Alege:";
- cin>>s;
- switch(s)
- {
- case 1 :
- {
- system ( "cls");
- cin>>n;
- ogl=0;
- c=n;
- while(c>0)
- {
- ogl=ogl*10 + c%10;
- c=c/10;
- }
- if(ogl==n)
- cout<<n<<"e palindrom";
- else
- cout<<n<<"nu e palindrom";
- break;
- }
- case 2 :
- {
- system ("cls");
- cin>>n;
- int nr=0;
- while(n>0)
- {
- nr=nr+1;
- n=n/10;
- }
- cout<<"numarul de cifre="<<nr;
- break;
- }
- case 3 :
- {
- system ("cls");
- cin>>n;
- for(int d=1; d<=n; d++)
- {
- if(n%d==0)
- cout<<d;
- }
- break;
- }
- case 4 :
- {
- system ( "cls");
- cout<<"Produdul cifrelor imapre";
- int z,p=1,ok=0;
- cin>>n;
- while(n>1)
- {
- z=n%10;
- if(z%2==1)
- {
- p=p*z;
- ok=1;
- }
- }
- n=n/10;
- if(ok==0)
- {
- cout<<"nu exista cfre impare ";
- else
- cout<<p;
- }
- break;
- }
- case 4 :
- {
- system ("cls")
- cout<<"Produsul cifrelor pare";
- p=1;
- ok=0;
- while(n>1)
- {
- z=n%10;
- if(z%2==0)
- {
- p=p*z;
- ok=1;
- }
- }
- n=n/10;
- if(ok==0)
- {
- cout<<"nu exista cifre pare";
- else
- cout<<p;
- }
- break;
- }
- //default:cout<<"Eroare";
- }
- cout<<endl;
- system ("pause");
- }while(s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement