OC 计算3位数字的排列 (豹子、对子、顺子、半顺、杂六)

2017-07-01  本文已影响0人  非农朗白卡斯被罚款

- (NSString*)calcGamePlayResult:(NSArray*)arr{

arr = [arrsortedArrayUsingComparator:^NSComparisonResult(id_Nonnullobj1,id_Nonnullobj2) {

return[obj1compare:obj2options:NSNumericSearch] ==NSOrderedDescending;

}];

NSString*a = [NSStringstringWithFormat:@"%@", arr[0]];

NSString*b = [NSStringstringWithFormat:@"%@", arr[1]];

NSString*c = [NSStringstringWithFormat:@"%@", arr[2]];

intA = [aintValue];

intB = [bintValue];

intC = [cintValue];

intE;

//计算豹子、对子

E = C - B ==0?1:0;

E = B - A ==0? ++E : E;

intF;

//计算顺子、半顺、杂六

F = C - B ==1?1:0;

F = B - A ==1? ++F :F;

NSString*value;

if(E ==1) {

value =@"对子";

}elseif(E ==2){

value =@"豹子";

}elseif(F ==1){

value =@"半顺";

}elseif(F ==2){

value =@"顺子";

}else{

value =@"杂六";

}

returnvalue;

}

上一篇下一篇

猜你喜欢

热点阅读