alexon5519

26-programare

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