— — — — — — — — — — — — — — — — — 2021.4.23 update — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Changes to the original computer character set method is allowed, but make some old software directly display garbled, because many of the software didn’t fit before utf-8, so today to update the new way, still come back to change vscode, is to seek along while didn’t find before, just directly to the computer, turn around and come back, I throw up

Ps: Code-runner is running without any problem, if you use F5 debugging or garbled code, after all, just changed the relevant Settings of code-runner, you can not expect him to directly change the CMD things.

steps

  1. File — — — — — — — preferences — — — — — — — — — — — set up — — — — — — — — — — – user — — — — — — — — — — — — — end — — — — — — – in the Settings. Edit in json

  1. Comment out all of them"code-runner.runInTerminal": true,To complete

— — — — — — — — — — — — — — — — — 2021.4.23 update — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

background

Win10 system, the compiler is MinGW

why

In VScode, the terminal is usually GBK (Runcoder, Powershell, CMD). Vscode usually defaults to UTF-8. If the encoding and decoding don’t match,

The solution

Win10 can set everything on the computer to UTF-8

  1. Set —— in the lower left cornerTime and Language

2. area——- drag it down and find it,Other date, time, and locale Settings———- and clickArea changes date, time, and number formats 3. Once inside,management———–Change system locale— — — — — — — — — — — — checkGlobal Language Support with Unicode UTF-8 (U)

  1. Reboot your computer and call it a day

The code that was being tested

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int binarySearch(vector<int>& nums, int target) {
    if(nums[0]>target || nums[nums.size(a)- 1]<target){
        return - 1;
    }
    int left = 0, right = nums.size(),mid=0;
    while(left<=right){
        mid = left + (right - left) / 2;
        if(nums[mid]==target){
            return mid;
        }else if(nums[mid]>target){
            right = mid - 1;
        }
        else if(nums[mid]<target){
            left = mid + 1; }}return - 1;   // when the loop condition is =
}


int main(a){
    vector<int> nums = { - 140..- 110..- 10.0.3.5.15.19.90.110.122.172.212};
    // Binary search
    int index = 0,target=19;
    index = binarySearch(nums, target);
    if(index! =- 1){
        cout << target << "The subscript in the array is:"<< index << endl;
    }


    // getchar();
    return 0;
}
Copy the code