ios 做的一个三个数求平均数 最大数 最小数
#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
ios 做的一个三个数求平均数 最大数 最小数的更多相关文章
- javascript基础程序(算出一个数的平方值、算出一个数的阶乘、输出!- !- !- !- !- -! -! -! -! -! 、函数三个数中的最大数)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 用ios做的一个简单的记事本
#import "ViewController.h" @interface ViewController ()@property (weak, nonatomic) IBOutle ...
- C#编写代码:求三个数中的最大数
static void Main(string[] args) { float x, y, z, temp; Console.Write(&q ...
- 谷歌面试题:输入是两个整数数组,他们任意两个数的和又可以组成一个数组,求这个和中前k个数怎么做?
谷歌面试题:输入是两个整数数组,他们任意两个数的和又可以组成一个数组,求这个和中前k个数怎么做? 分析: "假设两个整数数组为A和B,各有N个元素,任意两个数的和组成的数组C有N^2个元素. ...
- JAVA_新建一个方法并且求三个数中的最大值
package wac.wev.as;//新建一个方法在求最大值import java.util.Scanner; public class MaxLian {public static void m ...
- CF E. Vasya and a Tree】 dfs+树状数组(给你一棵n个节点的树,每个点有一个权值,初始全为0,m次操作,每次三个数(v, d, x)表示只考虑以v为根的子树,将所有与v点距离小于等于d的点权值全部加上x,求所有操作完毕后,所有节点的值)
题意: 给你一棵n个节点的树,每个点有一个权值,初始全为0,m次操作,每次三个数(v, d, x)表示只考虑以v为根的子树,将所有与v点距离小于等于d的点权值全部加上x,求所有操作完毕后,所有节点的值 ...
- acd LCM Challenge(求1~n的随意三个数的最大公倍数)
Problem Description Some days ago, I learned the concept of LCM (least common multiple). I've played ...
- 最接近的三数之和(给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数, 使得它们的和与 target 最接近。返回这三个数的和)
例如,给定数组 nums = [-1,2,1,-4], 和 target = 1. 与 target 最接近的三个数的和为 2. (-1 + 2 + 1 = 2). 思路:首先对数组进行排序 ...
- js求三个数的最大值运算
js代码: <script> // var num1 = 32, // num2 = 43, // num3 = 98; // if (num1 > num2) { // if (n ...
随机推荐
- ios 从前台返回到回台 从后台返回到前台 或者 支付宝支付订单后 对界面进行操作
正常情况下,在AppDelegate中实现下面两个方法,能够监听从后台恢复到前台 - (void)applicationDidEnterBackground:(UIApplication *)appl ...
- 【Python@Thread】queue模块-生产者消费者问题
python通过queue模块来提供线程间的通信机制,从而可以让线程分项数据. 个人感觉queue就是管程的概念 一个生产者消费者问题 from random import randint from ...
- 浙大pat 1031题解
1031. Hello World for U (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Giv ...
- use include to read a file
#include<iostream> #include<fstream> using namespace std; void process(string filename) ...
- informix建临时表索引
对于特殊字段,比如外键,主键,在不知道外键主键名的情况下,需要如下操作select constrname from sysconstraints where constrtype='R' and ta ...
- CDOJ 1270 Playfair(模拟)
题目链接 Playfair is a kind of substitution cipher.And the encryption role is simple.In general,there ar ...
- java中修饰符及其用法
1. java中的修饰符 a. 权限修饰符 private,默认的,protected,public b. 状态修饰符 static,final c. 抽象修饰符 abstract 2. 类修饰符 p ...
- [ An Ac a Day ^_^ ] CodeForces 468A 24 Game 构造
题意是让你用1到n的数构造24 看完题解感觉被样例骗了…… 很明显 n<4肯定不行 然后构造出来4 5的组成24的式子 把大于4(偶数)或者5(奇数)的数构造成i-(i-1)=1 之后就是无尽的 ...
- 关于erlang的binary
引自:http://cryolite.iteye.com/blog/1547252 1. binary数据是可以在不同进程间共享的 当然这些进程都在同一Erlang节点上. 这与普通term不同,后者 ...
- MySQL慢日志分析-转载
/path/mysqldumpslow -s c -t 10 /database/mysql/slow-log这会输出记录次数最多的10条SQL语句,其中: -s, 是表示按照何种方式排序,c.t.l ...