#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	float ws_a, a, ws_d, hit, s, t, wound, save, final;

	/* Read the relevant statistics */

	printf("Please enter the WS of the attacker: ");
	scanf("%f", &ws_a);
	printf("Please enter the number of attacks: ");
	scanf("%f", &a);
	printf("Please enter the WS of the defender: ");
	scanf("%f", &ws_d);
	printf("Please enter the strength of the attacks: ");
	scanf("%f", &s);
	printf("Please enter the toughness of the defender: ");
	scanf("%f", &t);
	printf("Please enter the defender's save (if no saves are allowed, enter 7): ");
	scanf("%f", &save);

	/* Calculate the average number of hits */

	if ( ws_d == 0 ) {hit = a * 1;}

	if ( ws_d == 1 && ws_a == 1 ) {hit = a * 3/6;}
	if ( ws_d == 1 && ws_a >= 2 && ws_a <= 10 ) {hit = a * 4/6;}
	
	if ( ws_d == 2 && ws_a >= 1 && ws_a <= 2 ) {hit = a * 3/6;}
	if ( ws_d == 2 && ws_a >= 3 && ws_a <= 10 ) {hit = a * 4/6;}

	if ( ws_d == 3 && ws_a == 1 ) {hit = a * 2/6;}
	if ( ws_d == 3 && ws_a >= 2 && ws_a <= 3 ) {hit = a * 3/6;}
	if ( ws_d == 3 && ws_a >= 4 && ws_a <= 10 ) {hit = a * 4/6;}
	
	if ( ws_d == 4 && ws_a == 1 ) {hit = a * 2/6;}
	if ( ws_d == 4 && ws_a >= 2 && ws_a <= 4 ) {hit = a * 3/6;}
	if ( ws_d == 4 && ws_a >= 5 && ws_a <= 10 ) {hit = a * 4/6;}

	if ( ws_d == 5 && ws_a >= 1 && ws_a <= 2 ) {hit = a * 2/6;}
	if ( ws_d == 5 && ws_a >= 3 && ws_a <= 5 ) {hit = a * 3/6;}
	if ( ws_d == 5 && ws_a >= 6 && ws_a <= 10 ) {hit = a * 4/6;}

	if ( ws_d == 6 && ws_a >= 1 && ws_a <= 2 ) {hit = a * 2/6;}
	if ( ws_d == 6 && ws_a >= 3 && ws_a <= 6 ) {hit = a * 3/6;}
	if ( ws_d == 6 && ws_a >= 7 && ws_a <= 10 ) {hit = a * 4/6;}

	if ( ws_d == 7 && ws_a >= 1 && ws_a <= 3 ) {hit = a * 2/6;}
	if ( ws_d == 7 && ws_a >= 4 && ws_a <= 7 ) {hit = a * 3/6;}
	if ( ws_d == 7 && ws_a >= 8 && ws_a <= 10 ) {hit = a * 4/6;}
	
	if ( ws_d == 8 && ws_a >= 1 && ws_a <= 3 ) {hit = a * 2/6;}
	if ( ws_d == 8 && ws_a >= 4 && ws_a <= 8 ) {hit = a * 3/6;}
	if ( ws_d == 8 && ws_a >= 9 && ws_a <= 10 ) {hit = a * 4/6;}

	if ( ws_d == 9 && ws_a >= 1 && ws_a <= 4 ) {hit = a * 2/6;}
	if ( ws_d == 9 && ws_a >= 5 && ws_a <= 9 ) {hit = a * 3/6;}
	if ( ws_d == 9 && ws_a == 10 ) {hit = a * 4/6;}

	if ( ws_d == 10 && ws_a >= 1 && ws_a <= 4 ) {hit = a * 2/6;}
	if ( ws_d == 10 && ws_a >= 5 && ws_a <= 10 ) {hit = a * 3/6;}

	/* Calculate the average number of wounds before armour saves */
	
	if ( s > t + 1 ) {wound = hit * 5/6;}
	if ( s == t + 1 ) {wound = hit * 4/6;}
	if ( s == t ) {wound = hit * 3/6;}
	if ( s == t - 1 ) {wound = hit * 2/6;}
	if ( s < t - 1 ) {wound = hit * 1/6;}

	/* Calculate the average number of wounds after armour saves */
	
	if ( save == 2 ) {final = wound * 1/6;}
	if ( save == 3 ) {final = wound * 2/6;}
	if ( save == 4 ) {final = wound * 3/6;}
	if ( save == 5 ) {final = wound * 4/6;}
	if ( save == 6 ) {final = wound * 5/6;}
	if ( save == 7 ) {final = wound * 1;}
	
	/* Print the average number of wounds */

	printf("The defender will suffer an average of %f wounds.\n", final);

}