iOS makes a three number to find the average maximum number of minimum number

Source: Internet
Author: User

#import "ViewController.h"

@interface Viewcontroller ()
@property (Weak, nonatomic) Iboutlet Uitextfield *one;//The first text to be entered this box uses the text button
@property (Weak, nonatomic) Iboutlet Uitextfield *two;//can enter the second text this box uses the text button
@property (Weak, nonatomic) Iboutlet Uitextfield *three;//can enter the third article box with the text button
@property (Weak, nonatomic) Iboutlet Uitextfield *max;//can output the maximum value of the text box with the textbox with the text button
@property (Weak, nonatomic) Iboutlet Uitextfield *pingjun;//the text box with the output average
@property (Weak, nonatomic) Iboutlet Uitextfield *min;//can output a text box with a minimum value

@end

@implementation Viewcontroller
-(Ibaction) Max: (ID) Sender {//Use the button button to click this button to get the maximum value
int a=self.one.text.intvalue;//assigns the value entered in the first text box to a
int b=self.two.text.intvalue;//assigns the value entered in the second text box to B
int c=self.three.text.intvalue;//assigns the value entered in the third text box to C
if (a>b) {//Here is a comparison method of three numbers in C language
if (a>c) {
Self.max.text=[nsstring stringwithformat:@ "%d", a];
}
Else
Self.max.text=[nsstring stringwithformat:@ "%d", c];
}else
if (b>c) {
Self.max.text=[nsstring stringwithformat:@ "%d", b];

}else
Self.max.text=[nsstring stringwithformat:@ "%d", c];
}
-(Ibaction) Pingjun: (ID) Sender {//Use the button button to click this button to get the minimum value
int a= ([self.one.text intvalue]+[self.two.text intvalue]+[self.three.text intvalue])/3;//directly adds the values entered in three text divided by 39.
Self.pingjun.text=[nsstring stringwithformat:@ "%d", a];

}
-(ibaction) min: (ID) Sender {//Use the button button to click this button to get the minimum value
int a=self.one.text.intvalue;
int b=self.two.text.intvalue;
int c=self.three.text.intvalue;
if (a<b) {
if (a<c) {
Self.min.text=[nsstring stringwithformat:@ "%d", a];
}
Else
Self.min.text=[nsstring stringwithformat:@ "%d", c];
}else
if (b<c) {
Self.min.text=[nsstring stringwithformat:@ "%d", b];

}else
Self.min.text=[nsstring stringwithformat:@ "%d", c];


}

-(void) Viewdidload {
[Super Viewdidload];
Additional setup after loading the view, typically from a nib.
}

-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}

@end

iOS makes a three number to find the average maximum number of minimum number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.