标签:color io ar for sp on c amp ad
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
//起点移动到(0,0)
CGContextMoveToPoint(context, 0, 0);
//画线到(100,100)
//CGContextAddLineToPoint(context, 100, 100);
CGContextAddRect(context, CGRectMake(100, 100, 200, 100));
CGContextAddEllipseInRect(context, CGRectMake(160, 110, 80, 80));
CGContextMoveToPoint(context, 100, 200);
CGContextAddLineToPoint(context, 100, 350);
//画边框
// CGContextStrokePath(context);
//只填充
// CGContextFillPath(context);
//设置填充色
[[UIColor redColor] setFill];
// [[UIColor colorWithRed:1 green:1 blue:1 alpha:1] setFill];
// //设置边框颜色
// [[UIColor blueColor] setStroke];
[[UIColor redColor] 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);
#include <stdio.h>
int sum1(int *a);
int sum2(int *a1,int *a2,int *a3);
int main(int argc, const char * argv[]) {
int math[5] = {90,89,78,68,99};
int phy[5] = {77,90,88,67,47};
int program[5] = {99,98,97,90,67};
int sum = 0;
for (int i =0; i < 5; ++i) {
sum = math[i] + phy[i] + program[i] + sum;
}
printf("sum:%d\n",sum);
printf("average:%d\n\n",sum/15);
printf("summath:%d\n",sum1(math));
printf("averagemath%d\n\n",sum1(math)/5);
printf("sumphy:%d\n",sum1(phy));
printf("averagephy:%d\n\n",sum1(phy)/5);
printf("sumprogram:%d\n",sum1(program));
printf("averageprogram:%d\n\n",sum1(program)/5);
printf("sumstudent1:%d\n",sum2(&math[0],&phy[0],&program[0]));
printf("averagestudent1:%d\n\n",(sum2(&math[0],&phy[0],&program[0]))/3);
printf("sumstudent2:%d\n",sum2(&math[1],&phy[1],&program[1]));
printf("averagestudent2:%d\n\n",(sum2(&math[1],&phy[1],&program[1]))/3);
printf("sumstudent3:%d\n",sum2(&math[2],&phy[2],&program[2]));
printf("averagestudent3:%d\n\n",(sum2(&math[2],&phy[2],&program[2]))/3);
printf("sumstudent4:%d\n",sum2(&math[3],&phy[3],&program[3]));
printf("averagestudent4:%d\n\n",(sum2(&math[3],&phy[3],&program[3]))/3);
printf("sumstudent5:%d\n",sum2(&math[4],&phy[4],&program[4]));
printf("averagestudent5:%d\n\n",(sum2(&math[4],&phy[4],&program[4]))/3);
return 0;
}
int sum1(int *a){
int sum = 0;
for(int i = 0;i < 5; i++) {
sum = a[i] + sum;
}
return sum;
}
int sum2(int *a1,int *a2,int *a3){
int sum = 0;
sum = *a1 +*a2+*a3;
return sum;
}
标签:color io ar for sp on c amp ad
原文地址:http://www.cnblogs.com/joee/p/3986691.html