feat(codes/cpp): revert the changes size_t back to int

This commit is contained in:
Gonglja
2023-01-13 15:07:12 +08:00
parent 78d7d07bd9
commit 845e70366d
5 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@ int main() {
vector<int> nums = { 1, 5, 3, 2, 4, 7, 5, 9, 10, 8 };
// 初始化哈希表
unordered_map<int, int> map;
for (size_t i = 0; i < nums.size(); i++) {
for (int i = 0; i < nums.size(); i++) {
map[nums[i]] = i; // key: 元素value: 索引
}
int index = hashingSearch(map, target);

View File

@ -9,7 +9,7 @@
/* 线性查找(数组) */
int linearSearch(vector<int>& nums, int target) {
// 遍历数组
for (size_t i = 0; i < nums.size(); i++) {
for (int i = 0; i < nums.size(); i++) {
// 找到目标元素,返回其索引
if (nums[i] == target)
return i;