标签:set 之间 集合 ESS ber default color ane eof
A B C D F
B F F C C A
D C E F
2.00
1.83
Unknown
#include<stdio.h> #include <string.h> void process(char str[]); int main(){ char str[200] = {}; while(gets(str) != 0){ process(str); memset(str,0,sizeof(str)); } return 0; } void process(char str[]){ int n = 0; char ch; double sum = 0.0; for(int i = 0; str[i] != ‘\0‘; i++){ ch = str[i];if(ch == ‘ ‘){ continue; } if(ch >= ‘A‘ && ch <= ‘D‘){ sum += 4-(ch - ‘A‘); n++; } else if(ch == ‘F‘){ sum += 0.0; n++; } else { printf("Unknown\n"); return; } } if(n != 0){ printf("%.2lf\n",sum/(double)n); } }
1、多行输入处理
字符串结尾判断,
str[i] != ‘\0‘
字符串清空原有内容
标签:set 之间 集合 ESS ber default color ane eof
原文地址:https://www.cnblogs.com/hiwjw/p/12569352.html