戴维营第三天上课总结

今天轮到大茶给我们讲课, 给我们更加详细的讲解各个数据类型, 以及其他关键字, 并且给我们演示怎么用代码编写一个计算器, 还有怎么算闰年, 左移等等知识点, 其中的代码有

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int16_t y = 14, m = 9, d =17;
    int16_t data = 0;

//y<<9                   //  0000  0000 0000 1110
           // 0001 1100 0000 0000
(在一年之内, 存储只到2^7, 所以前面9个0就是没意义的, 就缩写成第二个状态)
//(m<<12)>>7
    //  0000 0001 0010 0000
//(d<<11)>>11// 0000 0000 0001 0001

    data = (y<<9)|((m<<12)>>7)|((d<<11)>>11);

    printf("%02x\n", data);

    return 0;
}
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int year;

    printf("请输入年份: ");
    scanf("%d", &year);

    if((0 == year%4)||((0 == year%400)&&(0 != year%100)))
    {
        printf("是闰年\n");
    }
    else
        printf("不是闰年\n");

    return 0;
}
//
//  ViewController.m
//  demo2
//
//  Created by apple on 14-9-17.
//  Copyright (c) 2014年 apple. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
{
    NSString *op1, *op2;
    char op;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    op1 = @"";
    op2 = @"";
    // Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)button1clicked:(id)sender {
    NSLog(@"1 clicked");
    if (op != ‘+‘ && op != ‘-‘
        && op != ‘*‘ && op != ‘/‘) {
        //1231
        op1 = [NSString stringWithFormat:@"%@%d", op1,1];
    }else
    {
        op2 = [NSString stringWithFormat:@"%@%d", op2,1];
    }
}
- (IBAction)button2clicked:(id)sender {
    NSLog(@"2 clicked");
    if (op != ‘+‘ && op != ‘-‘
        && op != ‘*‘ && op != ‘/‘) {
        //1231
        op1 = [NSString stringWithFormat:@"%@%d", op1,1];
    }else
    {
        op2 = [NSString stringWithFormat:@"%@%d", op2,1];
    }
}
- (IBAction)button3clicked:(id)sender {
    NSLog(@"3 clicked");
    if (op != ‘+‘ && op != ‘-‘
        && op != ‘*‘ && op != ‘/‘) {
        //1231
        op1 = [NSString stringWithFormat:@"%@%d", op1,1];
    }else
    {
        op2 = [NSString stringWithFormat:@"%@%d", op2,1];
    }

}

- (IBAction)add:(id)sender {
    op = ‘+‘;
}
- (IBAction)jieguo:(id)sender {
    if (op == ‘+‘) {
        //NSString转int整形数值
        int a1 = [op1 intValue];
        int a2 = [op2 intValue];
        int sum = a1 + a2;
        NSLog(@"%d", sum);
        NSString *result = [NSString stringWithFormat:@"%d", sum];
        self.jieguo.text = result;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

由于题目和思路累积的少, 所以应付这些题非常的吃力, 不过还好还有其他同学可以一起交流, 给我详细的讲解其中的原由, 这让我茅舍顿开, 希望以后大家继续保持这种学习状态, 一起讨论一起交流~~~

时间: 2024-08-25 20:51:11

戴维营第三天上课总结的相关文章

Java第三次上课课堂试验博文

1.Java字段初始化的规律: 运行如下所示的代码 package demo; public class InitializeBlockDemo { /** * @param args */ public static void main(String[] args) { InitializeBlockClass obj=new InitializeBlockClass(); System.out.println(obj.field); obj=new InitializeBlockClass(

戴维营第七天上课总结

今天的内容是关于字符串, 指针, 数组这些问题, 要知道在C语言中是没有为字符串定义一个类型的, 只有用char[]的数组类型的方式存储字符串, 打印的时候使用%s 打印, 指针呢, 变量的地址称为指针, 而存储变量的称为指针变量, 指针也是一种变量. 用*加变量名设定变量. 指针的运算操作分为三种: 第一:对指针变量或者是指针变量组成的表达式进行运算. 第二:是间访操作. 第三:间访操作后对数组的元素进行计算. 数组:

第一零三天上课 PHP TP框架下控制器的方法分离

(1)配置信息 修改配置文件->Config.php (配置后,原先的控制方法无效) 'ACTION_BIND_CLASS' => TRUE, // 控制器方法分离 (2)在Controller文件夹下创建   和控制器类名  相同  的文件夹    (该文件夹即代替原来的控制器) (3)在新建的文件夹下书写方法类(该类即代替原来的控制器下的方法) <?php namespace Home\Controller\Index; //命名空间具体到类名(代替类的文件夹) use Think\

戴维营第三天

计算器制作,虽然很多代码老师已经写了,但是自己对着打还是遇到很多问题,虽然有些语法还是不太清楚,但是大致通过询问同学,老师.运行流程已经运行代码逻辑思想有一定了解了 #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel *wang; @end #import "ViewController.h" @in

戴维营第五天上课总结

今天大茶给我们讲了C语言的递归以及函数的调用, 函数的调用, 可以在其他文件中创建函数的源文件, 在main文件中进行调用, 可以节俭在main函数的多行代码, 一旦程序出错, 调试起来也非常的方便, 不需要在一大段的代码中慢慢寻找一些细小的错误. 递归的使用有些类似于循环, 一样有判断语句, 当判断语句不成立的时候, 跳过判断语句的条件, 进行到else语句进行递归运算, 一直到不满足条件为止. #include <stdio.h> int f(int n); int n; int main

戴维营第四天上课总结

今天大茶继续给我们讲解C语言的知识点, 以及注意事项, 由于没有基础, 所以学习进度非常的慢, 虽然有很多东西都难以理解, 但越是难以理解, 编程的魅力就越大, 哪怕是我只会让电脑输出一个hello, 我也是成就感十足, 编程世界的魅力难以抗拒, 今天大茶给我们布置了一道题目, 以我的能力, 我暂时写不出来, 所以我自己想了一些小题目来锻炼自己的逻辑思维能力, 以下就是我今天的代码 int row = 5, column = 5; //先设定行数和列数 for(int i = 0; i <= r

第三天上课

题目:输入两个数;若两个数的平方大于100,则输出百位以上的数字;若两个数的平方小于100,则输出两数之和;          Console.Write("请输入第一个数a=");          double a = double.Parse(Console.ReadLine());          Console.Write("请在输入一个数b=");          double b = double.Parse(Console.ReadLine())

面向对象程序设计-C++ Steam &amp; Vector 【第三次上课笔记】

大家可以下载后用Vim 或者 Sublime Text等文本编辑器查看 Conference: http://blog.csdn.net/candy1232009/article/details/7032526 //ofstream fout; //C style //fout.open("fout.txt"); ofstream fout ("fout.txt"); //C++ out stream recommend ifstream fin ("fi

学习Linux第三次上课笔记

**1.9 使用PuTTY远程连接Linux 1.下载PuTTY. 2.在虚拟机上查看IP地址,使用ifconfig命令. 3.如果在虚拟机上,敲ifconfig命令,没反应.那么使用 4.配置Putty,配置完成后,点击open按钮.最后一张是设置成功图. 5.如果没有成功,重启一下网络服务. (1)按windows+R键,输入cmd,然后Ping虚拟机的IP地址.看看你不能ping通.(2)在虚拟机上,重启网络服务.(3)putty上面重新配置,如上面的步骤一样. 注意:在Putty上面复制