Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #define STEP 0.001
- using namespace std;
- struct BB_formula
- {
- float p_sale;
- float p_ai;
- };
- float Hot100(float, float, float, BB_formula);
- int main()
- {
- static float tablica[10][3];
- float points[10];
- /*Tabela danych
- 0 - sales, 1 - AI, 2 - Streaming */
- tablica[1][0]=302;
- tablica[1][1]=89;
- tablica[1][2]=14.2;
- //Bass
- tablica[2][0]=106;
- tablica[2][1]=81;
- tablica[2][2]=11.6;
- //Kościól
- tablica[3][0]=176;
- tablica[3][1]=52;
- tablica[3][2]=7.0;
- //Animals
- tablica[4][0]=96;
- tablica[4][1]=141;
- tablica[4][2]=5.7;
- //SIO
- tablica[5][0]=83;
- tablica[5][1]=102;
- tablica[5][2]=9.4;
- BB_formula current;
- //float points[];
- int n=0;
- for(float w_sale=0; w_sale<=1; w_sale=w_sale+STEP)
- {
- for(float w_ai=0; w_ai<=1-w_sale; w_ai=w_ai+STEP)
- {
- current.p_sale=w_sale;
- current.p_ai=w_ai;
- for(int i=1; i<=5; i++)
- {
- float sp, ai,st;
- sp=tablica[i][0];
- ai=tablica[i][1];
- st=tablica[i][2];
- float p=Hot100(sp, ai, st, current);
- points[i]=p;
- }
- if(points[1]>=points[2]&&points[2]>=points[3]&&points[3]>=points[4]&&points[4]>=points[5])
- {
- //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;
- cout<<100*w_sale<<"\t"<<100*w_ai<<"\t"<<100*(1-w_sale-w_ai)<<endl;
- }
- //cout<<tablica[2][0]<<"\t"<<w_sale<<"\t"<<w_ai<<endl;
- }
- }
- }
- float Hot100(float sales, float AI, float streaming, BB_formula weights)
- {
- float w_sale=weights.p_sale;
- float w_ai=weights.p_ai;
- float w_str=1-w_sale-w_ai;
- return sales*w_sale+w_ai*AI+w_str*streaming;
- }
Advertisement
Add Comment
Please, Sign In to add comment