c语言如何把连续字母分别定义,怎样用C语言编写一个求平均数的程序?要求如下.刚学C语言,要求是:由五个大写英文字母(ABCDF,没有E)分别代表4,3,2,1,0五个数字,执行程序时,要求连续输入六个...

怎样用C语言编写一个求平均数的程序?要求如下.刚学C语言,

要求是:由五个大写英文字母(ABCDF,没有E)分别代表4,3,2,1,0五个数字,执行程序时,要求连续输入六个大写字母并用空格隔开(如A B F C D F ) ,输出时直接得到由这几个字母代表的数字的平均数并精确到两位小数(即(A+B+F+C+D+F)/6=(4+3+0+2+1+0)/6=1.67)

原题的英文要求如下,有可能翻译的不标准:

Each course grade is one of the following five letters:A,B,C,D,and F.(Note that there is no grade E.) The grade A indicates superior achievement,whereas F stands for failure.In order to calculate the GPA (Grade Point Average),the letter grades A,B,C,D,and F are assigned the following grade points,respectively:4,3,2,1,and 0.The GPA is the average number of these grades.

Input

The input data are 6 course grade in a line.There are 6 upper case letters,separated by blank spaces.

Output

If all upper case letters on a particular line of input came from the set {A,B,C,D,F} then the output will consist of the GPA,displayed with a precision of two decimal places.Otherwise,the message "Unknown letter grade in input" will be printed.

Sample Input

A B F C D F

B F F C C A

D C E F A B

A A A A A A

Sample Output

1.67

1.83

Unknown letter grade in input

4.00

作业帮用户2016-12-08举报

6c0a0adef10d1043fa4f41a7897345ed.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值