Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

1.

#include <iostream>

using namespace std;

int main()
{
int x,s=0,p=1,nrc=0;
cin>>x;
while(x!=0){
nrc++;
p=p*x%10;
s=s+x%10;
x=x/10;
}
cout<<s<<" "<<p<<" "<<nrc;

return 0;
}

2.
#include <iostream>

using namespace std;

int main()
{
int x,ogl=0;
cin>>x;
while(x!=0){
ogl=ogl*10+x%10;
x=x/10;
}
cout<<ogl;

return 0;
}
3.
#include <iostream>

using namespace std;

int main()
{
int x,ogl=0,cx;
cin>>x;
cx=x;
while(cx!=0){
ogl=ogl*10+cx%10;
cx/=10;
}
if(ogl==x){
cout<<"DA";
}else{
cout<<"NU";
}

return 0;
}

5.
#include <iostream>

using namespace std;

int main()
{
int x,ogl=0,f=0,i=1,a,b,c,d,e,p=1;
cin>>x;
a=x%10;
b=x/10%100;
d=x%100;
while(x!=0){
ogl=ogl*10+x%10;
x=x/10;
}
c=ogl%10;
e=ogl%100;
while(ogl!=0){
if(i%2!=0){
f=f+ogl%10*p;
p*=10;
}
i++;
ogl=ogl/10;
}
cout<<f;

return 0;
}
6.

#include <iostream>

using namespace std;

int main()
{
int x,i,c=0,cx,maxx;
cin>>x;
for(i=9;i>=1;i--){
cx=x;
if(c==0){
while(cx!=0){
if(cx%10==i){
maxx=i;
c++;
}
cx/=10;
}
}
}
cout<<maxx<<" "<<c;

return 0;
}
7.
#include <iostream>

using namespace std;

int main()
{
int x,i,c=0;
cin>>x;
while(x>9){
if(x%10!=x/10%10){
c++;
}
x/=10;
}
if(c==0){
cout<<"DA";
}else{
cout<<"NU";
}

return 0;
}

int main()
{
int n,nrf=0,i,p=1,c=0,cn,ok=0,x=0,cc,cnrf,nrc=0,ccc;
cin>>n;
for(i=9;i>=1;i--){
cn=n;
c=0;
while(cn!=0){
if(cn%10==i){
c++;
}
cn/=10;
}
cc=c/2;
ccc=c;
p=1;
if(c%2==0){
while(ccc!=0){
x=x*10+i;
ccc/=2;
}
cnrf=nrf;
while(cnrf!=0){
p*=10;
cnrf/=10;
}
nrf=nrf+x*p*10+x;
}else{
ok++;
}
}
if(ok==0 || ok==1){
cout<<nrf;
}else{
cout<<"NU";
}

return 0;
}

You might also like