Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <iostream>
- using namespace std;
- int oglinda(int x)
- {
- int aux=0;
- while(x){
- aux=aux*10+x%10;
- x/=10;
- }
- return aux;
- }
- int main()
- {
- cout<<oglinda(1234);
- return 0;
- }
- #include <iostream>
- using namespace std;
- int maxim(int x)
- {
- int V[15],n=0, ok, aux, nr=0;
- while(x){
- V[++n]=x%10;
- x/=10;
- }
- do{
- ok=1;
- for(int i=1;i<n;i++)
- if(V[i]<V[i+1]){
- aux=V[i];
- V[i]=V[i+1];
- V[i+1]=aux;
- ok=0;
- }
- }while(!ok);
- for(int i=1;i<=n;i++)
- nr=nr*10+V[i];
- return nr;
- }
- int main()
- {
- cout<<maxim(93678);
- return 0;
- }
- #include <iostream>
- #include <math.h>
- using namespace std;
- int concat(int a, int b)
- {
- int c1=0, aux, nr;
- aux=b;
- while(aux){
- c1++;
- aux/=10;
- }
- nr=a*pow(10, c1)+b;
- return nr;
- }
- int main()
- {
- cout<<concat(123, 321);
- return 0;
- }
- #include <iostream>
- using namespace std;
- int nr_prim(int a)
- {
- int i,ok=1;
- for(i=2;i*i<=a&&ok==1;i++)
- if(a%i==0)
- ok=0;
- return ok;
- }
- int main()
- {
- if(nr_prim(123))
- cout<<"Numarul este prim!";
- else
- cout<<"Numarul nu este prim!";
- return 0;
- }
- #include <iostream>
- using namespace std;
- int s_div(int a)
- {
- int i,s=0;
- for(i=2;i<=a;i++)
- if(a%i==0)
- s+=i;
- return s;
- }
- int main()
- {
- cout<<s_div(10);
- return 0;
- }
- #include <iostream>
- using namespace std;
- int nr_zero(int a)
- {
- int c=0;
- while(a){
- if(a%10 == 0)
- c++;
- a/=10;
- }
- return c;
- }
- int main()
- {
- cout<<nr_zero(10293010);
- return 0;
- }
- #include <iostream>
- using namespace std;
- void ulc_para(int a)
- {
- int gasit=0;
- while(a && !gasit){
- if((a%10)%2 == 0)
- gasit=1;
- else
- a/=10;
- }
- if(gasit)
- cout<<"Ultima cifra para este: "<<a%10;
- else
- cout<<"Nu exista numere pare!";
- }
- int main()
- {
- ulc_para(11111);
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement