Last active
March 17, 2018 00:10
-
-
Save ti-nspire/4bdebe4175c6224d733d6093cadc10cf to your computer and use it in GitHub Desktop.
QB Rating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
double contain(double var){ | |
double a; | |
double min = 0 ; | |
double max = 2.375; | |
a = (min < var)? var : min; | |
a = (a < max)? a : max; | |
return a; | |
} | |
int main(void){ // 型はとりあえず整数 int と実数 double の 2 つを覚えておく。 | |
double att, comp, yd, td, intcpt; | |
double a, b, c, d, rating; | |
printf("******** QB Rating ********\n"); | |
printf("Number of passing attempts (ATT)?\n"); | |
scanf("%lf", &att); // %lf は double 型でキー入力する書式指定。&att の & は変数のアドレスを得るという意味。 | |
printf("Number of completions (COMP)?\n"); | |
scanf("%lf", &comp); | |
printf("Passing yards (YDS)?\n"); | |
scanf("%lf", &yd); | |
printf("Touchdown passes (TD)?\n"); | |
scanf("%lf", &td); | |
printf("Interceptions (INT)?\n"); | |
scanf("%lf", &intcpt); | |
a = contain( (comp/att - 0.3) * 5 ); | |
b = contain( (yd/att - 3) * 0.25 ); | |
c = contain( 20 * td/att ); | |
d = contain( 2.375 - 25 * intcpt/att ); | |
rating = 100 * (a + b + c + d)/6; | |
printf("QB Rating = %0.1f\n", rating); // %0.1f の 1 は小数点以下の桁数 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment