可以帮我写出这个C语言程序来吗 Write a complete program that prompts how many students?reads the number.Make a loop for that many students,prompts the first student for name and how many tests,get name,number of tests.Make a loop to sum
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 00:34:00
可以帮我写出这个C语言程序来吗 Write a complete program that prompts how many students?reads the number.Make a loop for that many students,prompts the first student for name and how many tests,get name,number of tests.Make a loop to sum
可以帮我写出这个C语言程序来吗
Write a complete program that prompts how many students?reads the number.
Make a loop for that many students,prompts the first student for name and how many tests,get name,number of tests.Make a loop to sum all of her/his tests and compute the average of her/his test.Your program should output student name,test average and a letter grade.NOTE:to get credit you must write at least one function.
(if average >= 90,A,>=80,B etc.).
请高手帮我写个程序 要求输出的结果是 输入进去的有多少学生就输出每个学生的名字 平均成绩和 平均成绩得到的等级 >=90是A 80-90 B 70-80C 60-70 D 60以下F
可以帮我写出这个C语言程序来吗 Write a complete program that prompts how many students?reads the number.Make a loop for that many students,prompts the first student for name and how many tests,get name,number of tests.Make a loop to sum
需求不是很明确
简单起见 输入一个学生的信息处理并输出一个
程序如下
PS: 60以下为E
#include <stdio.h>char get_grade(float ave)
{
if(ave >= 90) return 'A';
if(ave >= 80) return 'B';
if(ave >= 70) return 'C';
if(ave >= 60) return 'D';
return 'E';
}
float calc_ave(char *name)
{
int n, i, s=0, t;
printf("How many tests for %s?\n", name);
scanf("%d", &n);
printf("Please input %d tests' scores\n", n);
for(i = 0; i < n; i ++)
{
scanf("%d", &t);
s += t;
}
return (float)s/n;
}
void main()
{
char name[20];
char grade;
float ave;
int n, i;
printf("How many students?\n");
scanf("%d", &n);
for(i = 1; i <= n; i ++)
{
printf("What's the name of %d%s students?\n", i, i%10 == 1 ? "st" : i%10==2?"nd":i%10==3?"rd":"th");
scanf("%s", name);
ave=calc_ave(name);
grade = get_grade(ave);
printf("%s %.2f %c\n", name, ave, grade);
}
}