关于视图与数据库的相关做作业
数据库与函数的理解,数据库,其实就是一些函数整合放在一个大集合了,,H文件里只有各种名字,另一个则具体介绍了各名字下的方法.h头文件中声明函数形式,如int function(int x),然后在源文件中 int function(type X) { 函数表达式} 且return int,如void,则void function(void),且return void.就是源文件需要写出一套完成的函数,而在头文件只用写出函数的调用格式.在给别人用的,由于是个人成果,可以只给头文件和那个.a的程序,这样别人可以借用,但是看不到具体内容,就如用printf(“”)一样,可以用,但是不会知道个人如何编码的.并且当真正运行后行成APP.运用到的函数会被整合进去,而有些头文件有的函数调用但过程中没有用到的则会自动剔除掉.并且可以宏定义来使一个版本可以有不同的选择语句,让一个编码过程长生多个适应不同对象的版本.宏定义的在运行之前就会被取代,而且不会考虑的类型问题.至于如何添加其他地方来的头文件,只需将.h文件与库复制到项目中即可,或者引用其他项目,这时候需要设置路径来查找别的工程的头文件,同时设置依赖关系,以防运行完对旧文件进行新的更改而导致现有的结果没有变化从而产生错误.
// // main.c // 数组 // // Created by 汪伟 on 14-9-22. // Copyright (c) 2014年 汪伟. All rights reserved. // #include <stdio.h> #define SIZE 5 int main() { int sum1=1; int sum2=2; int sum3=3; int math[SIZE]={91,67,88,78,81}; int physics[SIZE]={87,79,81,86,67}; int programming[SIZE]={86,81,85,92,87}; /*3个数组依次存数学,物理,程序设计的成绩*/ for(int i=0;i<SIZE;i++) { sum1=sum1+math[i];
// // sign.m // view // // Created by 汪伟 on 14-9-22. // Copyright (c) 2014年 汪伟. All rights reserved. // #import "sign.h" @implementation sign // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextMoveToPoint(context, 0,0); CGContextAddLineToPoint(context, 200, 0); CGContextAddArc(context, 200, 40, 40,M_PI_2, M_PI,0); CGContextAddArc(context, 200, 120, 40, M_PI_2,-M_PI,0); CGContextMoveToPoint(context, 0, 160); CGContextAddLineToPoint(context, 0, 0); CGContextAddLineToPoint(context, 0, 400); //CGContextAddRect(context,CGRectMake(100, 100, 200,100)); //CGContextAddEllipseInRect(context, CGRectMake(100, 100, 200, 100)); //画边框 //CGContextStrokePath(context); //只填充 //CGContextFillPath(context); //设置填充色 //[[UIColor redColor] setfill]; //[[UIColor colorWithRed:1 green:1 blue:0.5 alpha:0.5]setFill]; //设置边框颜色 //[[UIColor blueColor]setStroke]; //[[UIColor greenColor]set]; //even-odd,奇偶规则填充 CGContextDrawPath(context, kCGPathEOFillStroke); //CGContextMoveToPoint(context, 200, 200); //CGContextAddArc(context, 100, 200, 100, 0, M_PI_2,0); // CGContextAddLineToPoint(context, 0, 100); //control Point // CGContextAddCurveToPoint(context, 50, 0, 50, 200,100 ,100); // CGContextAddQuadCurveToPoint(context, 150, 0, 200, 100); // CGContextStrokePath(context); } @end
sum2=sum2+physics[i]; sum3=sum3+programming[i]; } printf("math:%d,physics:%d,program:%d\n",sum1,sum2,sum3); float S1=sum1; float S2=sum2; float S3=sum3; float average1=S1/SIZE; float average2=S2/SIZE; float average3=S3/SIZE; printf("math average:%.2f\nphysics average:%.2f\nprogram:%.2f\n",average1,average2,average3); return 0; }