alexon5519

24-programare

Feb 26th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6. int v[1000];
  7. int main(){
  8. ifstream f1("atestat.in");
  9. ofstream f2("atestat.out");
  10. int n,x,y,ver=0,i=0,p,ok=0,a,aux,j;
  11. f1>>n;
  12. while(f1>>x){
  13. y=x;
  14. i++;
  15. while(y >= 10)
  16. y=y/10;
  17. if(y == 0)
  18. i--;
  19. if(y != 0)
  20. v[i]=y;
  21. if(ver == 0){
  22. ver=1;
  23. p=x;
  24. }
  25. else
  26. if(ok == 0)
  27. if(p > x)
  28. ok=1;
  29. p=x;
  30. }
  31. if(ok == 0)
  32. f2<<"DA";
  33. else
  34. f2<<"NU";
  35. f2<<endl;
  36. for(a=1;a<=i-1;a++)
  37. for(j=a+1;j<=i;j++)
  38. if(v[a] < v[j]){
  39. aux=v[a];
  40. v[a]=v[j];
  41. v[j]=aux;
  42. }
  43. for(j=1;j<=i;j++)
  44. f2<<v[j];
  45. }
Add Comment
Please, Sign In to add comment