mateusz_r_93

Untitled

Nov 27th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #define STEP 0.001
  4.  
  5.  
  6.  
  7. using namespace std;
  8.  
  9. struct BB_formula
  10. {
  11. float p_sale;
  12. float p_ai;
  13.  
  14. };
  15. float Hot100(float, float, float, BB_formula);
  16.  
  17.  
  18.  
  19. int main()
  20. {
  21. static float tablica[10][3];
  22. float points[10];
  23.  
  24. /*Tabela danych
  25. 0 - sales, 1 - AI, 2 - Streaming */
  26.  
  27. tablica[1][0]=302;
  28. tablica[1][1]=89;
  29. tablica[1][2]=14.2;
  30.  
  31. //Bass
  32. tablica[2][0]=106;
  33. tablica[2][1]=81;
  34. tablica[2][2]=11.6;
  35.  
  36. //Kościól
  37. tablica[3][0]=176;
  38. tablica[3][1]=52;
  39. tablica[3][2]=7.0;
  40.  
  41. //Animals
  42. tablica[4][0]=96;
  43. tablica[4][1]=141;
  44. tablica[4][2]=5.7;
  45.  
  46. //SIO
  47. tablica[5][0]=83;
  48. tablica[5][1]=102;
  49. tablica[5][2]=9.4;
  50.  
  51.  
  52. BB_formula current;
  53. //float points[];
  54. int n=0;
  55.  
  56. for(float w_sale=0; w_sale<=1; w_sale=w_sale+STEP)
  57. {
  58. for(float w_ai=0; w_ai<=1-w_sale; w_ai=w_ai+STEP)
  59. {
  60. current.p_sale=w_sale;
  61. current.p_ai=w_ai;
  62.  
  63. for(int i=1; i<=5; i++)
  64. {
  65. float sp, ai,st;
  66. sp=tablica[i][0];
  67. ai=tablica[i][1];
  68. st=tablica[i][2];
  69. float p=Hot100(sp, ai, st, current);
  70. points[i]=p;
  71. }
  72.  
  73. if(points[1]>=points[2]&&points[2]>=points[3]&&points[3]>=points[4]&&points[4]>=points[5])
  74. {
  75. //cout<<100*w_sale/w_sale<<"\t"<<100*w_sale/w_ai<<"\t"<<100*w_sale/(1-w_sale-w_ai)<<"\t"<<points[3]<<"\t"<<points[4]<<endl;
  76. cout<<100*w_sale<<"\t"<<100*w_ai<<"\t"<<100*(1-w_sale-w_ai)<<endl;
  77. }
  78. //cout<<tablica[2][0]<<"\t"<<w_sale<<"\t"<<w_ai<<endl;
  79.  
  80. }
  81. }
  82.  
  83.  
  84.  
  85.  
  86. }
  87.  
  88. float Hot100(float sales, float AI, float streaming, BB_formula weights)
  89. {
  90. float w_sale=weights.p_sale;
  91. float w_ai=weights.p_ai;
  92. float w_str=1-w_sale-w_ai;
  93.  
  94. return sales*w_sale+w_ai*AI+w_str*streaming;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment