Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.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++ 输入整数时如何中断for循环? #包括 #包括 使用名称空间std; int i; INTE; INTP; 字符名[10]={}; 不能像这样做吗- #include <iostream> #include <stdlib.h> using namespace std; int i; int e; int p; char name[10] = {}; cout<<endl<<"Please enter the letters of your name separated by enter, when you are done, type 'quit' "<<endl; for (e=0; e <= 10; e++) { cin>>name[e]; if (name[e] == 'quit') { break; } } for (p=0; p < ; p++) { cout<<name[p]; } return 0; } #包括 #包括 #包括 使用名称空间std; int i; INTE; INTP; 载体名称; 不能用a来表示。另外,使用std::string收集数据和检查输入的大小也会更容易。“quit”是一个字符串,它包含4个字符。不能将其视为单个字符。因此,必须使用双引号“”而不是单引号“”。 此外,此字符串保存在字符数组中,而不是单个字符变量中。所以 #include <iostream> #include <stdlib.h> #include <vector> using namespace std; int i; int e; int p; vector<string> name; cout<<endl<<"Please enter the letters of your name separated by enter, when you are done, type 'quit' "<<endl; while(1) { string tmp; cin>>tmp; if (tmp == "quit") { break; } else if(tmp.size()>10) { cout<<"Enter name with less then 11 character"<<endl; } else { name.push_back(tmp); } } for (auto n : name) { cout<<n<<endl; } return 0; }_C++_Iphone_For Loop - Fatal编程技术网

C++ 输入整数时如何中断for循环? #包括 #包括 使用名称空间std; int i; INTE; INTP; 字符名[10]={}; 不能像这样做吗- #include <iostream> #include <stdlib.h> using namespace std; int i; int e; int p; char name[10] = {}; cout<<endl<<"Please enter the letters of your name separated by enter, when you are done, type 'quit' "<<endl; for (e=0; e <= 10; e++) { cin>>name[e]; if (name[e] == 'quit') { break; } } for (p=0; p < ; p++) { cout<<name[p]; } return 0; } #包括 #包括 #包括 使用名称空间std; int i; INTE; INTP; 载体名称; 不能用a来表示。另外,使用std::string收集数据和检查输入的大小也会更容易。“quit”是一个字符串,它包含4个字符。不能将其视为单个字符。因此,必须使用双引号“”而不是单引号“”。 此外,此字符串保存在字符数组中,而不是单个字符变量中。所以 #include <iostream> #include <stdlib.h> #include <vector> using namespace std; int i; int e; int p; vector<string> name; cout<<endl<<"Please enter the letters of your name separated by enter, when you are done, type 'quit' "<<endl; while(1) { string tmp; cin>>tmp; if (tmp == "quit") { break; } else if(tmp.size()>10) { cout<<"Enter name with less then 11 character"<<endl; } else { name.push_back(tmp); } } for (auto n : name) { cout<<n<<endl; } return 0; }

C++ 输入整数时如何中断for循环? #包括 #包括 使用名称空间std; int i; INTE; INTP; 字符名[10]={}; 不能像这样做吗- #include <iostream> #include <stdlib.h> using namespace std; int i; int e; int p; char name[10] = {}; cout<<endl<<"Please enter the letters of your name separated by enter, when you are done, type 'quit' "<<endl; for (e=0; e <= 10; e++) { cin>>name[e]; if (name[e] == 'quit') { break; } } for (p=0; p < ; p++) { cout<<name[p]; } return 0; } #包括 #包括 #包括 使用名称空间std; int i; INTE; INTP; 载体名称; 不能用a来表示。另外,使用std::string收集数据和检查输入的大小也会更容易。“quit”是一个字符串,它包含4个字符。不能将其视为单个字符。因此,必须使用双引号“”而不是单引号“”。 此外,此字符串保存在字符数组中,而不是单个字符变量中。所以 #include <iostream> #include <stdlib.h> #include <vector> using namespace std; int i; int e; int p; vector<string> name; cout<<endl<<"Please enter the letters of your name separated by enter, when you are done, type 'quit' "<<endl; while(1) { string tmp; cin>>tmp; if (tmp == "quit") { break; } else if(tmp.size()>10) { cout<<"Enter name with less then 11 character"<<endl; } else { name.push_back(tmp); } } for (auto n : name) { cout<<n<<endl; } return 0; },c++,iphone,for-loop,C++,Iphone,For Loop,这是完全错误的 if (name[e] == 'quit')

这是完全错误的

if (name[e] == 'quit')