我该怎么做if..else,do..while?如何检查输入值是否与数组中的任何值相匹配
该程序应提示用户输入学院名称并输出学院排名,如果用户输入的名称不正确,程序应输出一条消息,指出输入的名称不正确。
#include <iostream>
#include <string>
using namespace std;
int main()
{
string college[] = {"Baylor", "Colorado", "Iowa State",
"Kansas", "Kansas State", "Missouri",
"Nebraska", "Oklahoma", "Oklahoma State",
"Texas", "Texas A&M", "Texas Tech"};
int conferenceRanking[] = {12, 11, 10, 9, 5, 8,
3, 2, 7, 1, 6, 4};
for (if)
{
cout << "Enter the name of a Big Twelve College: " << college[count]
<< college << "\n's ranking is " << conferenceRanking[count]
<< "\n" << endl;
}
return 0;
}
[示例]这是我想拿出
Enter the name of a Big Twelve College: Nebraska
Nebraska's ranking is 3
这个'for(if)'究竟是什么? – DimChtz
['std :: find'](http://en.cppreference.com/w/cpp/algorithm/find)? – NathanOliver
,因为我不知道我要使用if..else还是做什么,我输入'for(if)'@DimChtz – Vadamadafaka