为什么编完C程序后,运行时输入数据按Enter键不能产生结果?
急需答案,希望大家给我解答,谢谢!我编的程序是:#include<stdio.h>intmain(){intnum1,num2,num3;intsum,Average,p...
急需答案,希望大家给我解答,谢谢!
我编的程序是:# include <stdio.h>
int main ()
{
int num1,num2,num3;
int sum,Average,product,smallest,largest;
smallest=0;
largest=0;
printf("Input three different integers:");
scanf("%d%d%d\n",&num1,&num2,&num3);
sum=num1+num2+num3;
printf("sum is %d\n",sum);
product=num1*num2*num3;
printf("product is %d\n",product);
Average=(num1+num2+num3)/3;
printf("Average is %d\n",Average);
largest=0;
if (num1>largest)
largest=num1;
if (num2>largest)
largest=num2;
if (num3>largest)
largest=num3;
printf("largest is %d\n",largest);
smallest=0;
if (num1<smallest)
smallest=num1;
if (num2<smallest)
smallest=num2;
if (num3<smallest)
smallest=num3;
printf("smallest is %d\n",smallest);
return 0;
}
调试并没有什么错误,但就是运行后输入数据不能进行下面的步骤了 展开
我编的程序是:# include <stdio.h>
int main ()
{
int num1,num2,num3;
int sum,Average,product,smallest,largest;
smallest=0;
largest=0;
printf("Input three different integers:");
scanf("%d%d%d\n",&num1,&num2,&num3);
sum=num1+num2+num3;
printf("sum is %d\n",sum);
product=num1*num2*num3;
printf("product is %d\n",product);
Average=(num1+num2+num3)/3;
printf("Average is %d\n",Average);
largest=0;
if (num1>largest)
largest=num1;
if (num2>largest)
largest=num2;
if (num3>largest)
largest=num3;
printf("largest is %d\n",largest);
smallest=0;
if (num1<smallest)
smallest=num1;
if (num2<smallest)
smallest=num2;
if (num3<smallest)
smallest=num3;
printf("smallest is %d\n",smallest);
return 0;
}
调试并没有什么错误,但就是运行后输入数据不能进行下面的步骤了 展开
2个回答
展开全部
请将
scanf("%d%d%d\n",&num1,&num2,&num3);
修改为:
scanf("%d%d%d",&num1,&num2,&num3);
去掉输入流中的\n字符
scanf("%d%d%d\n",&num1,&num2,&num3);
修改为:
scanf("%d%d%d",&num1,&num2,&num3);
去掉输入流中的\n字符
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
代码最好拿出来 这样比较好点 要不一个问题无从下手
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询