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

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 01:51:39
C语言两倒题目,请尽量精简语句.C语言两倒题目,请尽量精简语句.C语言两倒题目,请尽量精简语句.1、#includedoublef(doublex){if(xreturnx;elseif(x

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;
}