잘 쓰겠습니다. 스도쿠 퍼즐을 만들고 있습니다. 숫자가 이미 행에 존재하기 때문에 행에 들어갈 수 있는지 비교하려고합니다. 메신저 C에서 # 좋아하고 나는 당신 때문에 누군가가 내가 정확하게 비교할 수 있도록 저를 도울 수있는 C++와 지식의 부족으로 listConnectordown1[c] == fifth[i];
에 오류가 메신저를 볼 수있는이STD :: List in C++
for (int i= 0; i< fifth.size(); i++)
{
for (int c= 0; c<9; c++)
{
listConnectordown1[c] == fifth[i];
//then the number can not go in here because it already exists in the row but not the
block
}
}
있나요?
오류가 지금 벡터 주어진 조언을 변경
4 IntelliSense: no operator "[]" matches these operands
operand types are: std::list<int, std::allocator<int>> [ int ] j:\08227 acw\ACW\Sudoku\Sudoku\main.cpp 152
입니다, 지금은 예를 들어, 제거 할 필요가있을 때 특정 값을 제거하는 방법을 모르는
int possbileChecks[] = {1,2,3,4,5,6,7,8,9};
std::vector<int> fifth (possbileChecks, possbileChecks + sizeof(possbileChecks)/sizeof(int));
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
PossibleChecks = Block1[i][j];
if (!PossibleChecks == 0)
{
PossibleValuesInsideBlock[count] = PossibleChecks;
//ValueRemove = count-1;
possiblValuesCount = PossibleChecks-1;
fifth.Remove(PossibleChecks);
possiblValuesCount=0;
count = count++;
}
}
}
ᴋᴇʏsᴇʀ의 대답에 대한 보조 노트로,'std :: list'는 데이터 구조로 연결된 목록을 사용합니다. 링크 된리스트의 경우 랜덤 액세스는 'Big Oh (n)'복잡도를 가지며 배열의 경우 Big Oh (1)입니다. – mostruash
정확히 말하면, 처음부터 끝까지 (또는 이중으로 연결되어 있기 때문에) 전체 목록을 탐색해야합니다. – keyser
C++에서는'sizeof' 사용법이 필요하지 않습니다. – keyser