Skip to content

Instantly share code, notes, and snippets.

@housemeow
Forked from anonymous/functionPrototype.c
Last active December 24, 2015 07:59
Show Gist options
  • Save housemeow/6767767 to your computer and use it in GitHub Desktop.
Save housemeow/6767767 to your computer and use it in GitHub Desktop.
//輸出cost
double getTypeACost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeBCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeCCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeDCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeECost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
//輸出真正花費(cost低於資費時,還是得花資費的錢)
double getTypeARealCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeBRealCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeCRealCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeDRealCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
double getTypeERealCost(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
//算出Type的編號, 從1~5
int getCheapestType(double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS){
double minCost = getTypeARealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS);
int type = 1;
if(getTypeBRealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS)<minCost){
minCost = getTypeBRealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS);
type=2;
}
if(getTypeCRealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS)<minCost){
minCost = getTypeCRealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS);
type=3;
}
if(getTypeDRealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS)<minCost){
minCost = getTypeDRealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS);
type=4;
}
if(getTypeERealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS)<minCost){
minCost = getTypeERealCost(I-nc, E-nc, lc, I-n SMS, E-n SMS);
type=5;
}
return type;
}
//輸入Type的編號輸出type的錢
double getTypeCost(int type, double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
//輸入Type的編號輸出type真正的錢
double getTypeRealCost(int type, double I-nc, double E-nc, double lc, int I-n SMS, int E-n SMS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment