#include <iostream.h>
#include <conio.h>
#include <stdio.h>
void main()
{
int n,k ,a[100],i,temp;
clrscr();
cin>> n >>k;
for (i=0;i<n;i++)
cin>>a[i];
for (i=0;i<n;i++)
{
temp = a[i];
while( a[i]>0)
{
if (a[i]%k) break;
a[i]/=k;
}
if ( a[i]==1 && temp!=1 ) cout<< temp <<"\t";
}
getch();
}
#include <iostream.h> #include <conio.h> #include <stdio.h> void main() { int n, s=0 ,i,k; clrscr(); cin>>n; for (i=0 ; i<n ;i++) { cin>>k; s=s*10+k; } if (s%11==0) cout<<"YES"; else cout<<"NO"; getch(); }
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
void main()
{
int n, s=0 ,i,k;
clrscr();
cin>>n;
for (i=0;i<n;i++)
{
cin >> k;
if ( i%2== 0)
s-=k;
else
s+=k;
}
if ( s%11 == 0)
cout<<"YES";
else
cout<<"NO";
getch();
}
#include <iostream.h> #include <conio.h> #include <stdio.h> void main() { int n,s; clrscr(); cin >> n; while (n!=1) { if (n%2==0) n=n/2; else n=n*3+1; cout<<n<<"\t"; } getch(); }
#include <iostream.h> #include <conio.h> #include <stdio.h> void main() { int n,i,j, temp , a[100]; long int sum=0; clrscr(); cin>>n; for (i=0;i<n;i++) cin>>a[i]; for (i=0;i<n;i++) for(j=0;j<i;j++) if (a[i]<=a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } for (i=0;i<n;i++) sum = sum * 10 + a[i]; cout<<sum; getch(); }
#include <iostream.h> #include <conio.h> void main() { int n,i,j, a[100] , rep=0; clrscr(); cin>>n; for (i=0;i<n;i++) cin>>a[i]; for (i=0;i<n;i++) { rep=0; for (j=0; j<n; j++) if (a[i] == a[j]) rep++; if ( rep>n/2 ) break; } if (rep>n/2) cout<<a[i]; else cout<<"Not Exist"; getch(); }
#include <iostream.h> #include <conio.h> int sum1 (int a); int sum[10] = {6,2,5,5,4,5,6,3,7,6}; void main() { int a,b,i, max=1, num_max; clrscr(); cin>> a >>b; for (i=a;i<b;i++) { if(sum1(i) > max) { max=sum1(i); num_max=i; } } cout<< max <<"\t"<<num_max; getch(); } int sum1(int a) { int r=0; while(a>0) { r=r+sum[(a%10)]; a=a/10; } return r; }