降价机器人PTA无运行结果

img


运行不出结果

你的 scanf("%lf",&p)放在单独的for循环里,只有最后读取的p的值有用,for循环没有意义啊,scanf("%lf",&p)应该跟下面的for在一起。

第10行的 } 删掉
第11行末尾的 { 删掉

代码修改如下:

#include <stdio.h>
int main()
{
    int M,N,i,j;
    double p;
    scanf("%d %d",&M,&N);
    for (i=0;i<N;i++)
    {
        scanf("%lf",&p);
        for (j=0;j<N;j++)
        {
            if(p<M)
            {
                printf("On Sale! %.1lf\n",p);
            }
        }
    }
    return 0;
}

中间空格去掉。

img