您的位置:首页 > 其它

MOOC清华《程序设计基础》第4章:查找扑克牌(线性查找)

2017-06-30 18:59 316 查看
给出13张扑克牌,找出黑桃Q。

#include <iostream>
using namespace std;

int main()
{
int cards[13] = {101, 113, 303, 206, 405, 208, 311, 304, 410, 309, 112, 207, 402};
int pos = -1;
for(int i = 0; i < 13; i++)
if(cards[i] == 112)
{
pos = i;
break;
}
if(pos != -1)
cout << "黑桃Q是第" << pos + 1 << "张" << endl;
else
cout << "没找到" <<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐