BUPT-homework/pset13/1-1-GetScore.c

31 lines
445 B
C
Raw Normal View History

2021-12-09 17:26:31 +08:00
#include <stdio.h>
#define MAX 48
int getScore(char *s);
int main() {
char input[MAX];
int score;
scanf("%s", input);
score = getScore(input);
printf("%d\n", score);
return 0;
}
/* 请在这里填写答案 */
int getScore(char *s) {
int score = 0;
while (*s != '\0') {
if (*s == 'W') { // Win
score += 3;
} else if (*s == 'D') { // Draw
score += 1;
} // If lost, the score is unchanged
s++;
}
return score;
}