C语言代码求解释翻译,越详细越好!

#include "circle.h"

circle *circle_new()
{
circle *returnValue;

returnValue = (circle *) malloc(sizeof(circle));
memset(returnValue, 0, sizeof(circle));

return returnValue;
}

circleList *circleList_new(int noOfCircle)
{
circleList *returnValue;

returnValue = (circleList *) malloc(sizeof(circleList));
memset(returnValue, 0, sizeof(circleList));
returnValue->list = (circle **) malloc(sizeof(circle *)*noOfCircle);
returnValue->noOfCircle = noOfCircle;

return returnValue;
}

circle *circle_getCircle(circleList *aCircleList, int circleID)
{
circle *returnValue;

returnValue = aCircleList->list[circleID];

return returnValue;
}

void circle_print(circle *aCircle)
{
double x, y, radius;

x = aCircle->x;
y = aCircle->y;
radius = aCircle->radius;

printf("(%.5f, %.5f) with radius = %.5f\n", x, y, radius);
}

void circleList_print(circleList *aCircleList)
{
circle **list;
circle *aCircle;

int i;

int noOfCircle;

noOfCircle = aCircleList->noOfCircle;
list = aCircleList->list;

for (i = 0; i < noOfCircle; i++)
{
aCircle = list[i];
printf(" Circle %d \n", i);
circle_print(aCircle);
}
}

int circle_checkWhetherCircleCoverPoint(circle *aCircle, double x, double y)
{
int returnValue;

double centerX, centerY;
double radius;

double leftSide, rightSide;

double temp1, temp2;

centerX = aCircle->x;
centerY = aCircle->y;
radius = aCircle->radius;

temp1 = centerX - x;
temp2 = centerY - y;

leftSide = temp1*temp1 + temp2*temp2;
rightSide = radius*radius;

if (leftSide <= rightSide)
{
returnValue = 1;
}
else
{
returnValue = 0;
}

return returnValue;
}

第1个回答  2013-08-24
#include "circle.h"

//创建一个圆实例(分配内存)
circle *circle_new()
{
circle *returnValue;

returnValue = (circle *) malloc(sizeof(circle));
memset(returnValue, 0, sizeof(circle));

return returnValue;
}

//创建一个圆列表的实例(分配内存)
//noOfCircle表示该列表最多容纳多少个圆
//由于没有头文件,猜测该列表是通过一个数组模拟的。(list是一个圆指针的数组)
circleList *circleList_new(int noOfCircle)
{
circleList *returnValue;

returnValue = (circleList *) malloc(sizeof(circleList));
memset(returnValue, 0, sizeof(circleList));
returnValue->list = (circle **) malloc(sizeof(circle *)*noOfCircle);
returnValue->noOfCircle = noOfCircle;

return returnValue;
}

//根据指定的ID获得圆
//circleList *aCircleList(圆列表), int circleID(圆ID)
//返回指定的圆
circle *circle_getCircle(circleList *aCircleList, int circleID)
{
circle *returnValue;

returnValue = aCircleList->list[circleID];

return returnValue;
}

//打印一个圆,包括圆心坐标:x,y和半径r
void circle_print(circle *aCircle)
{
double x, y, radius;

x = aCircle->x;
y = aCircle->y;
radius = aCircle->radius;

printf("(%.5f, %.5f) with radius = %.5f\n", x, y, radius);
}

//打印一个列表中的所有的圆,
void circleList_print(circleList *aCircleList)
{
circle **list;
circle *aCircle;

int i;

int noOfCircle;

noOfCircle = aCircleList->noOfCircle;
list = aCircleList->list;

for (i = 0; i < noOfCircle; i++)
{
aCircle = list[i];
printf(" Circle %d \n", i);
circle_print(aCircle);
}
}

//检查一个圆(aCircle)是否覆盖某个点(x,y)
int circle_checkWhetherCircleCoverPoint(circle *aCircle, double x, double y)
{
int returnValue;

double centerX, centerY;
double radius;

double leftSide, rightSide;

double temp1, temp2;

centerX = aCircle->x;
centerY = aCircle->y;
radius = aCircle->radius;

temp1 = centerX - x;
temp2 = centerY - y;

leftSide = temp1*temp1 + temp2*temp2;
rightSide = radius*radius;

if (leftSide <= rightSide)
{
returnValue = 1;
}
else
{
returnValue = 0;
}

return returnValue;
}追问

好厉害。好多问题不懂,怎么联系你

本回答被提问者采纳
第2个回答  2013-08-24
太长了,这看着头疼啊追问

还有个800多行的。。。

C语言求过程 翻译清楚一点
这代码的意思应该是比较a、b的值,如果a大于b,交换a、b的值。具体来说就是:scanf让用户输入两个整型数值a、b 执行if判断,如果a>b,则执行{}内语句。这里的temp是个中间变量,a、b交换时,a的值赋给temp,然后b赋给a,这时如果没有这个中间变量是没有办法完成的,a的值已经变成了b的。所以...

C语言程序翻译 求高手逐句翻译
int m=1,n=1,f;char *b_name,*c_name;struct club *head_club,*p_club;int xuehao;int size_club=sizeof(struct club);全手打,希望能够帮到楼主

C语言程序求翻译
C语言程序求翻译 #include<stdio.h>intmain(){charstr[]="china";inti=0;while(str[i]!='\\0');{i++;}printf("字符串的长度为:%d\\n",i);return0;}... #include<stdio.h> int main() { char str[]="china"; int i=0; while(str[i]!='\\0'); { i++; } printf("字符串的长...

一段单片机C语言,求大神逐句翻译一下。
define uchar unsigned char \/\/变量关键字更改 include <intrins.h> \/\/头文件 uchar code tab[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xC0};\/\/字符数组定义 void delay() \/\/子函数定义 { uchar i,j; \/\/变量定义 for(i=0;i<15;i++...

求C语言高手详细翻译
0],i;for(i=0;i<5;i++){if(t>b[i]) t=b[i];} return t;} int kemu(int *c,int n)\/\/求最低成绩的科目 {int i, t=c[0],m=0;for(i=1;i<n;i++){if(t>c[i]) {t=c[i];m++;} } return m;} 此程序我只是照程序解释 程序内容的错对与我无关,在此申明!

C语言 跪求翻译 谢谢~~
void main (void){ PCA0MD &= ~0x40; \/\/ WDTE = 0 (清零看门口计时器的使能状态,就是让它不可用)Timer2_Init(); \/\/ 初始化Timer2,从而生成Timer2 ADC0_Init(); \/\/ 初始化模数转换器0 DAC0_Init (); \/\/ 初始化数模转换器0 SYSCLK_Init (); \/\/ 初始化振荡器 ...

求大神帮忙注释一下c语言,急啊,有\/\/的翻译就好了
led显示对应字码 } void main(){ P3=0xff;\/\/P3口置高电平 EA=1;EX0=1;PX0=1;TCON=0X01;\/\/ 初始化定时器0中断模式?P3=0xff;\/\/ EA=1;EX1=1;PX1=1;TCON=0X02; \/\/ 初始化定时器1中断模式?while(1){ disp();} } 个人经验不足,条件不足。只能解释道此种程度 ...

c语言 代码如下,为什么输出是29,求解释,越详细越好
解释执行结果之前先对全局变量和局部变量以及静态变量稍作解释:如果全局变量和局部变量同名时,在局部变量所在作用域内,使用的是局部变量的值,局部变量以外使用的是对应的全剧变量的值。在{}内定义的局部变量,作用域只在{}内,出了{}后使用的是对应的全局或对应局部变量的值。静态变量,只在定义...

C语言代码翻译
void wait ( int seconds ) \/\/定义一个具有等待功能的函数 { int a=0;clock_t endwait; \/\/clock_t 就是long 型 \/\/通过下面两部实现等待seconds秒的作用 endwait =clock()+seconds*CLK_TCK;while (clock()<endwait){} } void main(){ int t,m,s;printf("input counterdown time...

C语言 求翻译 谢谢~
你这个程序不全 差很多呀,这样有些变量和自定义函数的作用不是很确定,只能跟据英文意思差测下,已有的代码,我大概加了下注释,希望对你有用 main(){int t=1;char str[10],code[]={"090212"}; \/\/设定密码为090212 while (t==1){printf("please enter the password:");scanf("%s"...

相似回答