#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *one;//能够输入的第一个文本文框 用的是text按键
@property (weak, nonatomic) IBOutlet UITextField *two;//能够输入的第二个文本文框 用的是text按键
@property (weak, nonatomic) IBOutlet UITextField *three;//能够输入的第三个文本文框 用的是text按键
@property (weak, nonatomic) IBOutlet UITextField *max;//能够输出最大值的文本文框 用的是text按键
@property (weak, nonatomic) IBOutlet UITextField *pingjun;//能够输出平均值的文本文框 用的是text按键
@property (weak, nonatomic) IBOutlet UITextField *min;//能够输出最小值的文本文框 用的是text按键
@end
@implementation ViewController
- (IBAction)max:(id)sender { //用的是button按键 点击这个按键就能得到最大值
int a=self.one.text.intValue;//将第一个文本框中输入的值赋值给a
int b=self.two.text.intValue;//将第二个文本框中输入的值赋值给b
int c=self.three.text.intValue;//将第三个文本框中输入的值赋值给c
if(a>b){ //这里就是用的c语言中的三个数的比较法
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 { //用的是button按键 点击这个按键就能得到最小值
int a=([self.one.text intValue]+[self.two.text intValue]+[self.three.text intValue])/3;//直接将三个文本中输入的值相加在除以三九可以了
self.pingjun.text=[NSString stringWithFormat:@"%d",a];
}
- (IBAction)min:(id)sender { //用的是button按键 点击这个按键就能得到最小值
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];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end