codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
/* 姓名を以下のルールで加算 t, b +3 l, c +2 上記以外 +1 (最終の)総和が7の倍数の場合は 結果を1.5倍する (そうでない場合は 結果を総和 とする) */ #include <stdio.h> int calc_score(char *str) { int score = 0; while (*str) { switch (*str) { case 't': case 'b': score += 3; break; case 'l': case 'u': score += 2; break; default: score++; } str++; } return score; } int main() { char sei[100]; char mei[100]; int score = 0; printf("姓:"); scanf("%s", sei); printf("名:"); scanf("%s", mei); score = calc_score(sei); score += calc_score(mei); if ((score % 7) == 0) { /* 7の倍数なので 1.5倍する */ score = score * 3 / 2; } printf("ポイント: %d\n", score); return 0; }
Private
[
?
]
Run code
Submit