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 ...
随机推荐
- HBase表删除问题
HBase shell下用list命令查看表,出现错误:找不到表 格式化zookeeper,删除.opt/zookeeper下除了myid的文件 重启集群 再进入HBase shell,list可以查 ...
- Asp.net MVC 单元测试 简要笔记
首先要啰嗦几句. 单元测试是TDD的重要实践方法,也是代码质量的一种保证手段.在项目的工程化开发中,研发人员应该尽量保证书写Unit Test,即使不使用TDD. (VS中,我们可以直接使用微软提供的 ...
- linux下安装nginx+php
参考:http://blog.csdn.net/ihelloworld/article/details/7029796 http://blog.chinaunix.net/uid-21374062-i ...
- ZOJ 2710 Two Pipelines
计算几何+贪心 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm&g ...
- PHP学习过程_Symfony_(1)
从今天开始学习php,感兴趣的同学欢迎一块讨论学习,QQ群新群182983780; 1:配置环境变量 把这php和php5http://pan.baidu.com/s/1pKDq9tT两个文件同时c盘 ...
- 第六十七节,html表单元素
html表单元素 学习要点: 1.表单元素总汇 2.表单元素解析 本章主要探讨HTML5中表单元素,表单元素用于获取用户的输入数据. 一.表单元素总汇 HTML5的表单中,提供了各种可供用户输入的 ...
- 使用Toad创建存储过程出现错误并解决
存储过程中遇到ora-00942表或视图不存在 CREATE OR REPLACE PROCEDURE p IS CURSOR c IS SELECT * FROM scott.emp FOR UPD ...
- 一个ubuntu命令
curl 获取web curl www.baidu.com
- 【LeetCode】459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ...
- Sublime themes/ lint themes setup
[Sublime 3 Setup for ES6 / Babel] https://www.youtube.com/watch?v=L8nmOqyyJLA [config oceanic next t ...