zoukankan      html  css  js  c++  java
  • 变形方块

    // // ViewController.m // 变形方块 // // Created by 卿鹏 on 14-11-26. // Copyright (c) 2014年 qingpeng. All rights reserved. // #import "ViewController.h" @interface ViewController () { NSMutableArray *array; UIView *v; } @end @implementation ViewController int m1[16][4][4] ={ {{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}}, {{0,0,0,0},{1,1,1,1},{0,0,0,0},{0,0,0,0}}, {{0,0,0,0},{1,1,0,0},{0,1,1,0},{0,0,0,0}}, {{0,0,0,0},{0,0,1,1},{0,1,1,0},{0,0,0,0}}, {{0,0,0,0},{0,1,0,0},{1,1,1,0},{0,0,0,0}}, {{0,0,0,0},{0,1,1,1},{0,0,1,0},{0,0,0,0}}, {{1,0,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}}, {{0,0,0,1},{0,0,1,1},{0,0,0,1},{0,0,0,0}}, {{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,1,0,0}}, {{0,0,0,1},{0,0,0,1},{0,0,0,1},{0,0,1,1}}, {{1,1,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}}, {{0,0,1,1},{0,0,0,1},{0,0,0,1},{0,0,0,1}}, {{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}}, {{0,0,1,0},{0,0,1,1},{0,0,0,1},{0,0,0,0}}, {{0,0,0,0},{1,1,1,1},{0,0,0,0},{0,0,0,0}}, {{0,0,0,0},{0,1,1,0},{0,1,1,0},{0,0,0,0}} }; int n[4][4] = {{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. array = [[NSMutableArray alloc] init]; for(int i=0;i<16; i++) { int row = i % 4; int column = i / 4 ; v = [[UIView alloc] initWithFrame:CGRectMake(row*42+100, column*42+150, 40, 40)]; [array addObject:v];//添加一个OC中的View对象 [self.view addSubview:v]; } for(int x=0;x<4;x++)//初始化界面 { for(int y=0; y<4; y++) { UIView *k = array[x*4+y];//从数组中取出UIview if (n[x][y]) { k.backgroundColor = [UIColor blueColor]; } else { k.backgroundColor = [UIColor grayColor]; } } } } - (IBAction)didButton:(UIButton *)sender { static int n=0; if (n==15) { n = 0; } else { n ++; } for(int x=0;x<4;x++) { for(int y=0; y<4; y++) { UIView *k = array[x*4+y];//从数组中取出UIview if (m1[n][x][y]) { k.backgroundColor = [UIColor blueColor]; } else { k.backgroundColor = [UIColor grayColor]; } } } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
  • 相关阅读:
    UVALive 3664:Guess(贪心 Grade E)
    uva 1611:Crane(构造 Grade D)
    uva 177:Paper Folding(模拟 Grade D)
    UVALive 6514:Crusher’s Code(概率dp)
    uva 11491:Erasing and Winning(贪心)
    uva 1149:Bin Packing(贪心)
    uva 1442:Cave(贪心)
    学习 linux第一天
    字符编码问题
    orm 正向查询 反向查询
  • 原文地址:https://www.cnblogs.com/qingpeng-ios/p/4125256.html
Copyright © 2011-2022 走看看