Advertisement
alexon5519

10-programare crescator

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