Today it's big tea's turn to give us a lecture, give us a more detailed explanation of each data type, and other keywords, and show us how to use code to write a calculator, and how to calculate a leap year, shift left and other knowledge points. The code here is
# 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 (in a year, the storage is only 2 ^ 7, so the first 9 0 is meaningless, abbreviated as the second State) // (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 ("Enter the year:"); scanf ("% d", & year ); if (0 = year % 4) | (0 = year % 400) & (0! = Year % 100) {printf ("is a leap year \ n");} else printf ("not a leap year \ 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 :( I D) 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 to int integer value 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
Due to the small accumulation of questions and ideas, it is very difficult to deal with these questions. However, it is good that other people can communicate with each other and give me a detailed explanation of the reasons, we hope that you will continue to learn this kind of learning and discuss it together ~~~
Summary of the course on the third day of Camp David