请教C语言高手,这个continue究竟错在哪里?dev c++老是显示continue statement not within a loop
#include<stdio.h>#include<stdlib.h>intmain(void){constfloatMIN=0.0f;constfloatMAX=100...
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
const float MIN = 0.0f;
const float MAX = 100.0f;
float score;
float total = 0.0f;
int n = 0;
float min = MAX;
float max = MIN;
printf("Enter the first score (q to quit):");
while(scanf("%f", &score) == 1);
{
if(score < MIN || score > MAX)
{
printf("%0.1f is an invalid value.Try again: ",
score);
continue;
}
printf("Accpting %0.1f: \n", score);
min = (score < min)? score: min;
max = (score > max)? score: max;
total += score;
n++;
printf("Enter next score (q to quit):");
}
if(n > 0)
{
printf("Average of %d scores is %0.1f.\n", n, total / n);
printf("Low = %0.1f, higt = %0.1f\n", min, max);
}
else
printf("No valid scores were entered.\n");
system("pause");
return 0;
} 展开
#include<stdlib.h>
int main(void)
{
const float MIN = 0.0f;
const float MAX = 100.0f;
float score;
float total = 0.0f;
int n = 0;
float min = MAX;
float max = MIN;
printf("Enter the first score (q to quit):");
while(scanf("%f", &score) == 1);
{
if(score < MIN || score > MAX)
{
printf("%0.1f is an invalid value.Try again: ",
score);
continue;
}
printf("Accpting %0.1f: \n", score);
min = (score < min)? score: min;
max = (score > max)? score: max;
total += score;
n++;
printf("Enter next score (q to quit):");
}
if(n > 0)
{
printf("Average of %d scores is %0.1f.\n", n, total / n);
printf("Low = %0.1f, higt = %0.1f\n", min, max);
}
else
printf("No valid scores were entered.\n");
system("pause");
return 0;
} 展开
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
展开全部
while(scanf("%f", &score) == 1) 后面多了个分号,导致后面的continue没有在循环语句之中使用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
continue语句不能方在if语句中,只能放到循环语句中
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
while(scanf("%f", &score) == 1) 后面多了个分号!!!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询