1、创建一个drawboard
#import "DrawBoard1.h"
@implementation DrawBoard1
-(void)drawRect:(CGRect)rect{
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context,100,200);
CGContextAddLineToPoint(context,100,400);
CGContextAddCurveToPoint(context,100,400,400,250,100,200);
CGContextMoveToPoint(context, 75, 175);
CGContextAddLineToPoint(context,75,425);
CGContextAddCurveToPoint(context,75,425,500,250,75,175);
[[UIColor colorWithRed:1 green:1 blue:0 alpha:1]setFill];
CGContextDrawPath(context,kCGPathEOFillStroke);
CGContextAddEllipseInRect(context,CGRectMake(250,375,40,40));
CGContextAddEllipseInRect(context,CGRectMake(235,360,70,70));
[[UIColor colorWithRed:1 green:0 blue:0 alpha:1]setFill];
CGContextDrawPath(context,kCGPathEOFillStroke);
CGContextStrokePath(context);
}
@end
2、
#include<stdio.h>
int main(void)
{
int math[]={ 91,67,88,78,81};
int physize[]={ 87,79,81,86,67};
int programming[]={ 86,81,85,92,87};
int all_sum=0;
float all_average=0;
int subject_sum[3]={ 0,0,0};
float subject_average[3];
int student_sum[5];
float student_average[5];
int i=0;
for (i=0; i<=4; i++)
{
student_sum[i]=math[i]+physize[i]+programming[i];
student_average[i]=student_sum[i]/3.0;
subject_sum[0]+=math[i];
subject_sum[1]+=physize[i];
subject_sum[2]+=programming[i];
subject_average[0]=subject_sum[0]/5.0;
subject_average[1]=subject_sum[1]/5.0;
subject_average[2]=subject_sum[2]/5.0;
all_sum=subject_sum[0]+subject_sum[1]+subject_sum[2];
all_average=all_sum/5.0;
printf("%d同学的总成绩为%d,平均成绩为%f\n",i,student_sum[i],student_average[i]);}
printf("总成绩为%d,总平均成绩为%f\n数学总成绩为%d,数学平均成绩为%f,物理总成绩为%d,物理平均成绩为%f\n程序设计总成绩为%d,程序设计平均成绩为%f\n",all_sum,all_average,subject_sum[0],subject_average[0],subject_sum[1],subject_average[1],subject_sum[2],subject_average[2]);
return 0;
}
3,对与库的理解