Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++11 在对字符串向量进行迭代时,我遇到了一个问题_C++11_Visual Studio Code - Fatal编程技术网

C++11 在对字符串向量进行迭代时,我遇到了一个问题

C++11 在对字符串向量进行迭代时,我遇到了一个问题,c++11,visual-studio-code,C++11,Visual Studio Code,我试图制作一个程序,使用基于范围的字符串向量循环将数字转换为单词 // conversion of numbers into word #include<bits/stdc++.h> using namespace std; int main(){ vector<string> words = {"one", "two", "three","four","five","six", "seven", "eight", "n

我试图制作一个程序,使用基于范围的字符串向量循环将数字转换为单词

    // conversion of numbers into word 
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    vector<string> words = {"one", "two", "three","four","five","six", 
    "seven", "eight", "nine"};

    for(int x:words){
      cin>>num; 
      if(num==words[x]) cout<<words[x]; 
    } 
    return 0;
}


// this program is showing error:
{
"message": "no suitable conversion function from\"std::__cxx11::string\" to \"int\" exists",

}
//将数字转换为单词
#包括
使用名称空间std;
int main(){
向量词={“一”、“二”、“三”、“四”、“五”、“六”,
“七”、“八”、“九”};
for(int x:words){
cin>>num;

如果(num==words[x])可能与您的问题有关,但请同时阅读,并请花一些时间阅读,以及。请学习如何创建一个适当的、复制您所询问的问题且不包含任何无关问题的问题(您的示例就是这样做的)最后,关于你问的问题:请阅读更多关于它的内容和它的迭代。如果你想继续学习C++,可能是一个重要的投资。也许这可以作为一个副本来关闭。