zoukankan      html  css  js  c++  java
  • (1+2+3-1-2)*1*2/1/2=?李冬强

    主要代码

    //

    //  ViewController.m

    //  Cal-0710

    //

    //  Created by apple on 14-7-10.

    //  Copyright (c) 2014年 戴维营教育. All rights reserved.

    //

    #import "ViewController.h"

    @interface ViewController ()

    @property (weak, nonatomic) IBOutlet UILabel *label;

    @end

    @implementation ViewController

    - (IBAction)but0:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10;

               self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but3:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+3;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+3;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but4:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+4;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+4;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but5:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+5;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+5;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but6:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+6;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+6;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but7:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+7;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+7;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but8:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+8;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+8;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)but9:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+9;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+9;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)chenFa:(id)sender {

        cale.op='*';

           //    self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        if (a) {

            

            

            cale.a1=[cale fun:a];

            cale.a2=0;

            a=cale.op;

        }

        else {

            a=cale.op;

            

            self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        }

    }

    - (IBAction)chuFa:(id)sender {

         cale.op='/';

    //           self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        if (a) {

            

            

            cale.a1=[cale fun:a];

            cale.a2=0;

            a=cale.op;

        }

        else {

            a=cale.op;

            

            self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        }

    }

    - (IBAction)jian:(id)sender {

         cale.op='-';

          //     self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        if (a) {

            

            

            cale.a1=[cale fun:a];

            cale.a2=0;

            a=cale.op;

        }

        else {

            

            a=cale.op;

            self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        }

    }

    - (IBAction)clear:(id)sender {

        self.label.text=@"0";

        cale.a1=0;

        cale.a2=0;

        cale.op=0;

        

    }

    - (IBAction)but1:(id)sender {

        if(cale.op!=0)

        {

            

            cale.a2=cale.a2*10+1;

            self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

            

                         

        }

        else

        {

            cale.a1=cale.a1*10+1;

               self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

            

        }

    }

    - (IBAction)but2:(id)sender {

        if(cale.op!=0)

        {

            cale.a2=cale.a2*10+2;

               self.label.text=[NSString stringWithFormat:@"%f",cale.a2];

        }

        else

        {

            cale.a1=cale.a1*10+2;

               self.label.text=[NSString stringWithFormat:@"%f",cale.a1];

        }

    }

    - (IBAction)jia:(id)sender {

        cale.op='+';

        if (a) {

            

            

            cale.a1=[cale fun:a];

            cale.a2=0;

            a=cale.op;

        }

        else {

        a=cale.op;

        

           self.label.text=[NSString stringWithFormat:@"%c",cale.op];

        }

    }

    - (IBAction)dengYu:(id)sender {

        float result=[cale fun:cale.op];

        self.label.text=[NSString stringWithFormat:@"%f",result];

    }

    - (void)viewDidLoad {

        [super viewDidLoad];

        // Do any additional setup after loading the view, typically from a nib.

        

        cale=[[Cale alloc]init];

        NSLog(@"xx%c",cale.op);

        

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    @end

  • 相关阅读:
    总结
    设置导航栏上面的内容
    统一所有控制器导航栏左上角和右上角内容
    直接设置UIView的x,y,width,height...
    block浅析
    const浅析
    - (BOOL)isEqual:(id)object
    数据存入沙盒
    swift感悟2
    swift自学感悟1
  • 原文地址:https://www.cnblogs.com/lidongq/p/3836595.html
Copyright © 2011-2022 走看看