C语言两倒题目,请尽量精简语句.

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 12:53:13

C语言两倒题目,请尽量精简语句.
C语言两倒题目,请尽量精简语句.

C语言两倒题目,请尽量精简语句.
1、
#include
double f(double x)
{
if (x < 1)
return x;
else if (x < 10)
return 3 - x / 5;
else
return 3 * x - 11;
}
int main()
{
double x[3] = {0.5, 5, 50};
int i;
for (i = 0; i < 3; i++)
printf("f(%.2lf) = %.2lf\n", x[i], f(x[i]));
return 0;
}
2、
#include
int main()
{
int score;
char level;
printf("Input the score: ");
scanf("%d", &score);
if (score == 100) level = 'A';
else if (score < 60) level = 'E';
else level = 'A' + 9 - score / 10;
printf("Level: %c\n", level);
return 0;
}