为什么代码不将任何内容打印为输出? [英] Why code is not printing anything as output?

查看:71
本文介绍了为什么代码不将任何内容打印为输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按Ctrl + D后,我希望此代码可以打印数组,但不执行任何操作。

After pressing Ctrl+D, i am expecting this code to print array, but its doing nothing.

#include<stdio.h>

int main(){
    int k,i=0,a;
    int b[10];
    while(scanf("%d",&a)!=EOF){
        if(a>(a/4+a/3+a/2))
        b[i]=a;
        else
        b[i]=(a/4+a/3+a/2);
        i++;
    }
    for(k=0;k<=i;k++){
        printf("%d\n",b[k]);
    }
    return 0;
}


推荐答案

您使用的是错误的组合键可在您的操作系统(Windows 8)上生成EOF。在类似Unix的系统上,通常使用 Ctrl + D ,但是Windows系统通常使用 Ctrl + Z

You're using the wrong key combination to generate an EOF on your operating system (Windows 8). Ctrl+D is common on unix-like systems, but Windows systems generally use Ctrl+Z.

请注意,如果您不在空白行中,则可能必须两次使用 Ctrl + Z (刷新当前输入行,然后一次生成EOF。

Note that you might have to use Ctrl+Z twice if you're not on an empty line (once to flush the current line of input, and once to generate the EOF).

这篇关于为什么代码不将任何内容打印为输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆