Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _MUSKETEER_C_
- #define _MUSKETEER_C_
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <stdbool.h>
- float computeSurvivalRate(int *hp1, int* hp2, int* q1, int* q2, int *d)
- {
- // Write your code here.Please!
- float result, P1, P2, h = 0; // variable "result" as same as p(R)
- if(((*hp1) == 777) && ((*q1) >= (*q2))) (*d) = 100; // if hp1 = 777 and musketeer is Aramis => d = 100
- if((*hp2) == 888 && (*hp1) != 777 & (*hp1 != 888) && ((*hp1) != 900)) {
- // musketeer is de Jussac
- result = 0.01;
- return result;
- }
- if(((*hp1) == 999) && ((*hp2) == 888)) {
- // musketeer is d'Artagnan
- result = 1;
- return result;
- }
- if((*q1>1.5*(*q2)) && (*d <= 300)){
- puts("case 1");
- P1 = (*hp1) + (((*q1) - (*q2)) * (*d)) / (*q1);
- P2 = (*hp2);
- result = (P1 + h - P2)/(P1 + P2);
- }else if((*q1*1.5<(*q2)) && (*d >= 700)){
- puts("case 2");
- P1 = (*hp1);
- P2 = (*hp2) + (((*q1) - (*q2)) * (1000-(*d))) / (*q2);
- result = (P1 + h - P2)/(P1 + P2);
- }else {
- puts("case 3");
- P1 = (*hp1);
- P2 = (*hp2);
- h = ((int)(P1 + P2)) % 100;
- if((*hp1 == 888) && ((*hp2) > 888)) h *= 3; // musketeer is Porthos => power * 3
- result = (P1 + h - P2)/(P1 + P2);
- if(((*d) == 1000 && (*hp1) == 999) || ( ((*d) == 1000)) && h ==99) return result; else if((*d) == 1000) return 0; // d == 1000
- }
- if((*hp1) == 900 && result < 0.5 && (*q1) < (*q2) && (*hp2) != 888) {
- // (*hp2) != 888 bypass c-vidu5-d-vidu6
- puts("case 4");
- result = 0.5; // musketeer is Athos
- }
- return result;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement