fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a; cin >> a;
  6. int x, min = 2000000, max = 0;
  7. int i = 1, imin, imax;
  8. while(cin >> x) {
  9. if(x < min) {
  10. min = x;
  11. imin = i;
  12. }
  13. if(x < max) {
  14. max = x;
  15. imax = i;
  16. }
  17. i++;
  18. }
  19. cout << imin << ' ' << imax;
  20. }
  21.  
Success #stdin #stdout 0s 5288KB
stdin
5
8 2 9 4 5 
stdout
2 21984