tungggg

append cpp

Mar 6th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main (){
  4. int n;
  5. cin>>n;
  6. double a[1005];
  7. for(int i=0;i<n;i++){
  8. cin>>a[i];
  9. }
  10. double k;
  11. cin>>k;
  12. int vt;
  13. for(int i=0;i<n;i++){
  14. if (a[i]>k){
  15. vt=i;
  16. break;
  17. }
  18. }
  19. for(int i=n;i>=vt;i--){
  20. a[i]=a[i-1];
  21. }
  22. n++;
  23. a[vt]=k;
  24. for(int i=0;i<n;i++){
  25. cout<<fixed<<setprecision (2)<<a[i]<<" ";
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment