Hi~ o(* ̄▽ ̄*)ブ,终于又有项目啦《读心术》!!
闲话少说,上代码!!!!!!!!!!!!
#include#include#includeusing namespace std;
int main()
{
int i, a[4], ans;
string t[4];
t[0] = "1, 2, 3, 4, 5, 6, 7";
t[1] = "1, 3, 5, 7";
t[2] = "2, 3, 6, 7";
t[3] = "4, 5, 6, 7";
cout << "读心术猜数" << endl;
cout << "请你从下面7个数中, 选一个并记在心里。" << endl;
cout << t[0] << endl;
for (int i = 1; i <= 3; ++i)
{
cout << i << "问:下面的数有吗?0:没有, 1:有" << endl;
cout << t[i] << endl;
do
{
cin >> a[i];
}while(a[i] < 0 || a[i] > 1);
}
ans = 4 * a[3] + 2 * a[2] + a[1];
cout << "你心中想的数是:";
cout << ans << endl;
return 0;
}
OK啊好吧,拜拜!!
本站作者已申明原创,禁止转载!
文章内容属作者个人观点,不代表本站立场,如有侵权立删。






