标题:while语句
只看楼主
misaluoniqi
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-10-18
 问题点数:0 回复次数:1 
while语句
while(1), break 语句想要暂停一下但是使用system("pause")不管用,每次都是得出结论后直接退出程序了,这样的话应该怎么做呢?如下图
    while (1)
    {
        printf("A enter:");
        sacnf_s("%d", &t);
        i++;
        if (t == n)
        {
            printf("Congratulations playerA is right, he or she spent %d times to guess the correct answer", i);
            system("pause"); 此处system("pause")不管用 ,加至break 后仍然直接跳出
            break;
        }
        else if (t>n)
            printf("This character is too high\n.");
        else
            printf("This character is too low\n.");
        system("pause");
        system("cls");

[此贴子已经被作者于2016-10-18 22:06编辑过]

搜索更多相关主题的帖子: correct system guess 
2016-10-18 21:27
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:0 
不知道你想干什么  但是这段代码是可以pause的

程序代码:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int t;
    while (1)
    {
        printf("A enter:");
        scanf("%d", &t);
        if (t == 5)
        {
            printf("Congratulations playerA is right, he or she spent %d times to guess the correct answer");
            system("pause"); //此处system("pause")不管用 ,加至break 后仍然直接跳出
            break;
        }
    }
    return 0;
}

DO IT YOURSELF !
2016-10-19 09:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-469953-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.545443 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved