...+分支)急急在线等!用最初级的算法啊!新手新手!

发布网友 发布时间:2024-10-24 13:24

我来回答

2个回答

热心网友 时间:2024-10-31 20:11

#include <stdio.h>
int main()
{
float score[10];//存储输入的分数
float max, min, sum;//存储最高分,最低分和总分
int i, j;

scanf("%f", &score[0]);
max = min = score[0];//首先假设输入的第一个分数是最高分和最低分
sum = score[0];
for(i=1; i<10; i++)//然后输入剩下的9个分数
{
scanf("%f", &score[i]);

sum += score[i];

if(score[i]>max) max = score[i];
else if(score[i]<min) min = score[i];
}

sum = sum - max -min;//减去最高分和最低分

printf("%.3f\n", sum/8.0);
}

热心网友 时间:2024-10-31 20:11

#include <stdio.h>

static int g_lMinScore = 10;
static int g_lMaxScore = 0;
static float g_lTotalScore = 0;

int main(int argc, char **argv)
{
int i = 0;
int value = 0;

while(i < 10)
{
printf("Input No. %d score: ",i+1);
scanf("%d",&value);
if(value < 0 || value > 10)
{
printf("Input error,please input again\n");
continue;
}

if(value > g_lMaxScore)
{
g_lMaxScore = value;
}

if(value < g_lMinScore)
{
g_lMinScore = value;
}

g_lTotalScore += value;

i ++;
}

g_lTotalScore = g_lTotalScore - g_lMaxScore - g_lMinScore;
g_lTotalScore /= 8;

printf("Max score: %d, Min score %d\n", g_lMaxScore,g_lMinScore);
printf("Result score: %.2f\n", g_lTotalScore);

return 0;
}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com