1
Je suis presque à mi-chemin pour obtenir le pourcentage de deux entiers dont j'ai juste besoin d'aide pour l'obstacle final, voici mon codage ci-dessous fonctionne mais parfois c'est comme oui = 50 et non = 20 % quand il devrait être 50/50.Obtenir le pourcentage de deux entiers
int yes;
int no;
//Work out percentages
if ([VotedAnswer.text isEqualToString:@"No"]){
yes = [currentYes intValue];
no = [currentNo intValue] + 1;
}else{
yes = [currentYes intValue] + 1;
no = [currentNo intValue];
}
int total = yes + no + 1;
int pcntYes = (yes *100)/total;
int pcntNo = (no *100)/total;
float barNo = pcntNo/100.0f;
float barYes = pcntYes/100.0f;
//Set percent labels
yesPercent.text = [NSString stringWithFormat:@"%d%%", pcntYes];
noPercent.text = [NSString stringWithFormat:@"%d%%", pcntNo];
//Set Percent Bars
YesProgress.progress = barYes;
NoProgress.progress = barNo;
Im un retard laissez-moi vérifier – user393273