【发布时间】:2016-08-01 14:30:55
【问题描述】:
如果..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;
}
[sample] 这是我想要的输出
Enter the name of a Big Twelve College: Nebraska
Nebraska's ranking is 3
【问题讨论】:
-
这个
for (if)到底是什么? -
因为我不确定我会使用 if..else 还是 do while,所以我输入了
for (if)@DimChtz