alexon5519

21-programare

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