Advertisement
yoyoboyss

Untitled

May 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream.h>
  2.  
  3. void main(){
  4. int n, i, amin, bmin;
  5. int v[1000];
  6.  
  7. cout << "n= "; cin >> n;
  8. for(i = 0; i < n; i++){
  9. cout << "v[" << i << "]= ";
  10. cin >> v[i];
  11. }
  12. amin = v[0];
  13. bmin = v[1];
  14. for(i = 2; i < n; i++){
  15. if(v[i] < amin){
  16. if(amin < bmin)
  17. bmin = amin;
  18. amin = v[i];
  19. } else if(v[i] < bmin) {
  20. if(amin > bmin)
  21. amin = bmin;
  22. bmin = v[i];
  23. }
  24. }
  25. if(amin < bmin)
  26. cout << "\n" << amin << ' ' << bmin;
  27. else
  28. cout << "\n" << bmin << ' ' << amin;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement