I'm a super noob at c++. For some reason this sorting code wont work, any help would be great thanks! The method i'm attempting to use is selection sort.
#include "stdafx.h" #include <algorithm> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { const int nTotalSize = 5; int data[nTotalSize] = { 7, 47, 1, 8, 2 }; for (int iii = 0; iii < 5; iii++) { int nCurrentSmall = iii; for (int jjj = iii+1; jjj < nTotalSize; jjj++) { if (data[jjj] < data[iii]) { nCurrentSmall = jjj; } } swap(data[iii], data[nCurrentSmall]); } for (int iii = 0; iii < 5; iii++) { cout << data[iii] << endl; } return 0; }
data[iii]after theswapand checking if it matches expectations?