previous | index | next

Desired Behavior

Want code so that

  const int SIZE = 10;
  int v[SIZE];

  for (int i = 0; i < SIZE; i++) { // Fill the array with random integers
    v[i] = rand() % 100;
  }

  for (int i = 0; i < SIZE; i++) { // Display the unsorted array
    cout << v[i] << "  ";
  }
    
  // Sort v using selection sort
  ...
    
  cout << endl;
  for (int i = 0; i < SIZE; i++) { // Display the sorted array
    cout << v[i] << "  ";
  }

produces

  83  86  77  15  93  35  86  92  49  21  
  15  21  35  49  77  83  86  86  92  93

previous | index | next