加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

卡在C中的乘法表中

发布时间:2020-12-16 10:41:43 所属栏目:百科 来源:网络整理
导读:我是C编程的新手.我试图编写一个接受用户整数的程序,并将其乘法表显示为10倍. 这是我的计划: #include stdio.hint main (){ int number; int count = 1; int sum; printf("Enter a number to display its table: "); scanf(" %i ",number); while (count =1
我是C编程的新手.我试图编写一个接受用户整数的程序,并将其乘法表显示为10倍.
这是我的计划:

#include <stdio.h>

int main ()
{
        int number;
        int count = 1;
        int sum;

        printf("Enter a number to display its table: ");
        scanf(" %i ",&number);

        while (count <=10)
                {
                    sum = number * count;
                    printf("%i x %i = %in",number,count,sum);
                    count += 1;
                }
return 0;
}

编译成功完成,但是当我执行输出文件时,没有任何反应,终端无所事事,我要按ctrl c退出..

解决方法

这是由于scanf命令中使用的空格.

如果用它替换它

scanf("%i",&number);

你得到即时回应.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读