C++


SUBMITTED BY: sandub69

DATE: June 19, 2019, 10:45 p.m.

FORMAT: Text only

SIZE: 391 Bytes

HITS: 1777

  1. #include<iostream.h>
  2. #include<math.h>
  3. int main(){
  4. int n,mic=0,mare=0,c[4],i,cif=1,aux,sortat;
  5. cout<<"n=";cin>>n;
  6. while(n!=0){
  7. c[cif]=n%10;
  8. n=n/10;
  9. cif++;
  10. }
  11. do{
  12. sortat=1;
  13. for(i=1;i<4;i++)
  14. if(c[i]>c[i+1]){
  15. sortat=0;
  16. aux=c[i];
  17. c[i]=c[i+1];
  18. c[i+1]=aux;
  19. }
  20. }while(!sortat);
  21. for(i=1;i<=4;i++){
  22. mare=pow(10,4-i)*c[5-i]+mare;
  23. }
  24. cout<<"mare este:"<<mare<<endl;
  25. return 0;
  26. }

comments powered by Disqus