Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 280
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,x,y,p=-1,c=0;
- cin>>n;
- while(n!=0)
- {
- x=n;
- y=0;
- while(x)
- y=10*y+x%10,x/=10;
- if(y==n)
- if(n>p)
- p=n,c=1;
- else
- if(n==p)
- c++;
- cin>>n;
- }
- if(p>-1)
- cout<<p<<" "<<c;
- else
- cout<<"NU EXISTA";
- return 0;
- }
- 1582
- #include <iostream>
- using namespace std;
- int n, smin, smax, x, cx, s, xmin, xmax, i;
- int main()
- {
- cin>>n;
- smin=100; smax=0;
- for ( i=1;i<=n;i++)
- {
- cin>>x;
- cx=x;
- s=0;
- while (cx>0)
- {
- s=s+cx%10;
- cx=cx/10;
- }
- if (s<smin)
- {
- smin=s;
- xmin=x;
- }
- if (s>smax)
- {
- smax=s;
- xmax=x;
- }
- }
- cout<<xmin<<"\n"<<xmax;
- return 0;
- }
- 372
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,a ,b,C=0,x,sx,y,sy;
- cin >> n >> a;
- for(int i = 2 ; i <= n ; ++i)
- { cin >> b; x = a; y = b; sx = sy = 0;
- while(x)
- sx += x % 10,
- x /= 10;
- while(y)
- sy += y % 10,
- y /= 10;
- if(sx%2 != sy%2)
- C++;
- a=b; }
- cout << C;
- return 0; }
- 464
- #include <iostream>
- using namespace std;
- int main()
- {
- unsigned int k,x,ct=0;
- cin>>k>>x;
- while(x)
- {
- if(x%2==0)
- {
- while(x)
- {
- if(x%10==k)
- ct++;
- x/=10;
- }
- }
- cin>>x;
- }
- cout<<ct;
- return 0;
- }
- 442
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- long long a=0,b=0,i,n,n2,j,p;
- cin>>n; i=0; n2=n;
- while(n)
- {
- n/=10;
- i++;
- }
- n=n2;
- p=1;
- for(j=1;j<=i/2;j++) {
- b=b+p*(n%10);
- p*=10;
- n/=10;
- }
- if(i%2) n/=10;
- a=n;
- cout<<abs(a-b);
- }
- 362
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,x,c,s=0,i=0;
- cin >> n;
- x=n;
- while(x!=0)
- {
- c=x%10;
- i++;
- if(i%2==0)
- s+=c;
- x/=10;
- }
- cout << s;
- }
- 340
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,s;
- cin>>n;
- while(n>9)
- {
- s=0;
- while (n>0)
- {
- s=s+n%10;
- n=n/10;
- }
- n=s;
- }
- cout<<n;
- return 0;
- }
- 2221
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, nr = 0;
- cin >> n;
- int cn = n;
- while(cn > 0)
- {
- nr++;
- cn = cn / 10;
- }
- int cnt = 0;
- for(int i=0; i<nr; i++)
- {
- cn=n;
- int poz=0,nnou=0,p=1;
- while(cn>0)
- {
- if(poz!=i)
- {
- nnou=nnou+(cn%10)*p;
- p=p*10;
- }
- cn=cn/10;
- poz++;
- }
- if(nnou%3==0)
- cnt++;
- }
- cout<<cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement