-1

嗨,我是 xcode 的新手,使用 if 语句表示重量

int weight;

if (weight <10) { 
([ input.text * @" 100 " Floatvalue); }

if (weight 10-20){ 
([ input.text == 1000 + 50 for each kg more than 10);}

if (weight >20 ){
([ input.text == 1000 + 20 for each kg more than 20);}
4

1 回答 1

2

如果我理解您的问题(例如,我收集到您希望您的输出为字符串),以下内容可能对您有用:

if (weight < 10) {
    input.text = [NSString stringWithFormat:@"%d", 100 * weight];  // I'm not really sure what you wanted to do here.
}
else if (weight > 20) {
    input.text = [NSString stringWithFormat:@"%d", 1000 + 20 * (weight - 20)];
}
else {
    input.text = [NSString stringWithFormat:@"%d", 1000 + 50 * (weight - 10)];
}
于 2012-07-18T06:55:05.283 回答