[visual-studio]调试 c + + 程序时,得到一个空白的屏幕

标签: Visual-Studio
发布时间: 2014/3/1 4:00:18
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

现在 (在编辑后的代码) 会发生什么的就是每当我键入多个单词,它有痉挛。任何修复程序吗?谢谢你。抱歉如果我看起来像什么也不懂。贵的书和没人教我有我读教程在线。(对编辑的代码是下面。

#include <iostream>
#include <string>
using namespace std;

string qu;

int y;

int main()
{
y = 1;
while (y == 1)
{
    cout << "Welcome to the magic 8-ball application." <<"\nAsk a yes or no question, and the 8-ball will answer." << "\n";
    cin >> qu;
    cout << "\nProccessing...\nProccessing...\nProccessing...";
    cout << "The answer is...: ";
    int ans = (int)(rand() % 6) + 1;
    if (ans == 1)
        cout << "Probably not.";
    if (ans == 2)
        cout << "There's a chance.";
    if (ans == 3)
        cout << "I don't think so.";
    if (ans == 4)
        cout << "Totally!";
    if (ans == 5)
        cout << "Not a chance!";
    if (ans == 6)
        cout << "75% chance.";
    system("CLS");
    cout << "\nWant me to answer another question?" << "(1 = yes, 2 = no.)";
    cin >> y;
    }

return 0;

}

解决方法 1:

 while (y = 1);

应该是

 while (y == 1)

你有额外 ; ,应该使用 ==

官方微信
官方QQ群
31647020