Advertisement
Guest User

musketeer.c

a guest
Oct 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. #ifndef _MUSKETEER_C_
  2. #define _MUSKETEER_C_
  3.  
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <math.h>
  7. #include <stdbool.h>
  8.  
  9. float computeSurvivalRate(int *hp1, int* hp2, int* q1, int* q2, int *d)
  10. {
  11.     // Write your code here.Please!
  12.     float result, P1, P2, h = 0; // variable "result" as same as p(R)
  13.     if(((*hp1) == 777) && ((*q1) >= (*q2))) (*d) = 100; // if hp1 = 777 and musketeer is Aramis => d = 100
  14.     if((*hp2) == 888 && (*hp1) != 777 & (*hp1 != 888) && ((*hp1) != 900)) {
  15.         // musketeer is de Jussac
  16.         result = 0.01;
  17.         return result;
  18.     }
  19.  
  20.     if(((*hp1) == 999) && ((*hp2) == 888)) {
  21.         // musketeer is d'Artagnan
  22.         result = 1;
  23.         return result;
  24.     }
  25.  
  26.     if((*q1>1.5*(*q2)) && (*d <= 300)){
  27.         puts("case 1");
  28.         P1 = (*hp1) + (((*q1) - (*q2)) * (*d)) / (*q1);
  29.         P2 = (*hp2);
  30.         result = (P1 + h - P2)/(P1 + P2);  
  31.  
  32.     }else if((*q1*1.5<(*q2)) && (*d >= 700)){
  33.  
  34.         puts("case 2");
  35.         P1 = (*hp1);
  36.         P2 = (*hp2) + (((*q1) - (*q2)) * (1000-(*d))) / (*q2);
  37.         result = (P1 + h - P2)/(P1 + P2);
  38.  
  39.     }else {
  40.  
  41.         puts("case 3");
  42.         P1 = (*hp1);
  43.         P2 = (*hp2);
  44.         h = ((int)(P1 + P2)) % 100;
  45.         if((*hp1 == 888) && ((*hp2) > 888)) h *= 3; // musketeer is Porthos => power * 3
  46.         result = (P1 + h - P2)/(P1 + P2);
  47.         if(((*d) == 1000 && (*hp1) == 999) || ( ((*d) == 1000)) && h ==99) return result; else if((*d) == 1000) return 0; // d == 1000
  48.     }
  49.  
  50.     if((*hp1) == 900 && result < 0.5 && (*q1) < (*q2) && (*hp2) != 888) {
  51.         // (*hp2) != 888 bypass c-vidu5-d-vidu6
  52.         puts("case 4");
  53.         result = 0.5; // musketeer is Athos
  54.     }
  55.    
  56.     return result;
  57. }
  58.  
  59. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement