殷东亮的博客

Ubuntu 下部署 Django 应用

Jul 11, 2015
DevOps, Python, Linux, MySQL, Django

做了一个Django小应用,主要内容是一个论坛,经过好几天的研究,也可以在服务器端运行了,以下所有代码中的操作都需要在命令行运行。 安装MySQL # apt-get update apt-get install mysql-server mysql-client 根据提示设置 MySQL root用户密码 MySQL设 ...

iOS 中添加按钮和按钮监听方法

Sep 1, 2014
Objc, Xcode

代码添加按钮和按钮监听方法 // ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)tapButton:(UIButton *)sender{ NSLog(@"我是%@",[sender.titleLabel text]); } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setFrame:CGRectMake(100, 100, 200, 200)]; [button setTitle:@"hello" forState:UIControlStateNormal]; [button ...

iOS 中 textFieldShouldReturn 方法的使用

Aug 31, 2014
Objc, Xcode

iOS 中 textFieldShouldReturn 方法定义在 UITextFieldDelegate 协议中 // ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (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. } - (BOOL)textFieldShouldReturn:(UITextField *)textField{ if (textField==_name) { [_passwd becomeFirstResponder]; }else if(textField==_passwd){ [self login:nil]; } return YES; } - (IBAction)login:(id)sender { [self.view endEditing:NO]; NSString *name = _name.text; NSString *passwd = _passwd.text; [_lable setText:[NSString stringWithFormat:@"username:%@ password:%@",name,passwd]]; } @end

数据结构与算法实验课 - 链表

Oct 22, 2013
C/C++

ListA()创建一个链表并插入一个元素,ListB()创建一个链表并删除两个数之间的元素。 #include <stdio.h>#include <stdlib.h>#include <malloc.h>#include <string.h>#define NULL 0 void listA(){ static int n; int *p,i,k,x; printf("请输入n的长度:\n"); scanf("%d",&n); p=(int *)malloc(n*sizeof(int)); printf(& ...

Thinking in Java 习题 - 第七章

Oct 19, 2013
Java

练习2 # //从Detergent中继承产生一个新的类,覆盖scrub()并添加一个名为sterilize()的新方法。 class Cleanser{ private String s = "Cleanser"; public void append(String a ){ s+=a; } public void dilute(){ append(" dilute()"); } public void apply(){ append(" apply()"); } public void scrub(){ append(" scrub()"); } public String toString(){ return s; } public static void ...

Thinking in Java 习题 - 第六章

Sep 30, 2013
Java

练习1 # package access; //在某个包中创建一个类,在这个类所处的包的外部创建该类的一个实例。 public class Test1{ public Test1 (){ System.out.println("实例"); } } import access.*; public class Test { public static void main (String args[]){ new Test1(); } } 练习2 ...

Thinking in Java 习题 - 第五章

Sep 21, 2013
Java

练习1 # /*创建一个类,它包含一个未初始化的String引用。验证该引用被Java初始化成了null。*/ class Main { static String s; public static void main (String args[]){ System.out.println("s="+s); } }/*Output: s=null */ 练习2 # /*创建一个类,它包含一个在定义时就被初始化了的St ...

Thinking in Java 习题 - 第四章

Sep 13, 2013
Java

练习1 # /*写一个程序,打印从1到100的值*/ class Main { public static void main (String args[]){ for (int i=1;i<101;i++){ System.out.println(i); } } } 练习2 # /*写一个程序,产生25个随机数。对于每一个随机值,使用if-else语句来将其分类为大于,小于,或等于紧随它而 ...

Thinking in Java 习题 - 第三章

Sep 12, 2013
Java

练习1 # /*使用“简短的”和正常的打印语句来编写一个程序。*/ import java.util.*; import static net.mindview.util.Print.*; public class Main { public static void main(String[] args) { print("Hello World !"); System.out.println("Hello world !"); } }/*Output: Hello World ! Hello world ! */ 导入包时花了不少劲,util前面两个文件夹好像缺少文件编译不了,于是直接删了, ...

Thinking in Java 习题 - 第二章

Sep 8, 2013
Java

练习1 # /*创建一个类,它包含一个int域和一个char域, 他们都没有被初始化,将他们打印出来, 以验证java执行了默认初始化。*/ public class Test{ int i; char c; public Test(){ System.out.println("i="+i); System.out.println("c=["+ c + ']'); } public static void main(String[] args){ new Test(); } }/*output: i=0 c=[ ] */ 练习2 # /* ...


© 2012-2024 YINDONGLIANG