c语言程序错误。函数定义错误。
#include"stdio.h"main(){voidpointcircle(void);voidpointpoint(void);voidtimetran(void)...
#include "stdio.h" main () { void pointcircle(void); void pointpoint(void); void timetran(void); void numbers(void); int select; printf ("Please choose your own select:\n"); select=getchar(); switch(select){ case 1:pointcircle();break; case 2:pointpoint();break; case 3:timetran();break; case 4:numbers();break; default : printf ("Wrong choose!"); } void pointcircle(void) { int xx,yy,zx,zy,rr; float r1,r2; printf("x,y,x,y,r\n"); scanf("%d,%d,%d,%d,%d",&xx,&yy,&zx, &zy,&rr); r1=zx-xx; r2=zy-yy; if((r1*r1+r2*r2)<(rr*rr)) printf("在里面") else if ((r1*r1+r2*r2)==float(rr*rr))//继续判断 printf ("On"); else printf("Out");//完成 }
void pointpoint(void) { int xx,yy,zx,zy; //创建全局变量来保存 数据 printf ("Please input your own number:坐标1(x,y),坐标2(x,y)?"); scanf("%d,%d,%d,%d",&xx,&yy,&zx,&zy ); if ((xx>zx)&&(yy>zy))//判断条件 printf("点1优于点2"); else if ((xx<zx)&&(yy<zy)) printf ("点2优于点 1");//输出 else printf("谁也不优于 谁!"); }
void timetran(void) { int secs,hour,min,sec;//创建变量 printf ("Please input your own secs!\n"); scanf ("%d",&secs);//输入并赋值给变量 hour=secs/3600;//计算过程 min=(secs/60)-hour*60; sec=secs%60; printf ("Now is %d:%2d:%2d ",hour,min,sec);//输出 }
void numbers(void) { int nub;// 创建变量 printf("Please input your number!"); scanf ("%d",&nub);//输入内容并赋值给变 量 if (nub<10)//判断 printf ("%d is less than 10!",nub); else if (nub<100) printf ("%d is less than 100!",nub); else if (nub<1000 ) printf ("%d is less than 1000!",nub); else printf ("%d is more than 1000!",nub);//输出 }
--------------------Configuration: 333 -Win32 Debug--------------------Compiling... 333.cpp C:\Users\Administrator\Desktop\333.cpp(19) : error C2601: 'pointcircle' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(37) : error C2601: 'pointpoint' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(51) : error C2601: 'timetran' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(62) : error C2601: 'numbers' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(75) : fatal error C1004: unexpected end of file found 执行 cl.exe 时出错.
333.obj - 1 error(s), 0 warning(s) 展开
void pointpoint(void) { int xx,yy,zx,zy; //创建全局变量来保存 数据 printf ("Please input your own number:坐标1(x,y),坐标2(x,y)?"); scanf("%d,%d,%d,%d",&xx,&yy,&zx,&zy ); if ((xx>zx)&&(yy>zy))//判断条件 printf("点1优于点2"); else if ((xx<zx)&&(yy<zy)) printf ("点2优于点 1");//输出 else printf("谁也不优于 谁!"); }
void timetran(void) { int secs,hour,min,sec;//创建变量 printf ("Please input your own secs!\n"); scanf ("%d",&secs);//输入并赋值给变量 hour=secs/3600;//计算过程 min=(secs/60)-hour*60; sec=secs%60; printf ("Now is %d:%2d:%2d ",hour,min,sec);//输出 }
void numbers(void) { int nub;// 创建变量 printf("Please input your number!"); scanf ("%d",&nub);//输入内容并赋值给变 量 if (nub<10)//判断 printf ("%d is less than 10!",nub); else if (nub<100) printf ("%d is less than 100!",nub); else if (nub<1000 ) printf ("%d is less than 1000!",nub); else printf ("%d is more than 1000!",nub);//输出 }
--------------------Configuration: 333 -Win32 Debug--------------------Compiling... 333.cpp C:\Users\Administrator\Desktop\333.cpp(19) : error C2601: 'pointcircle' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(37) : error C2601: 'pointpoint' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(51) : error C2601: 'timetran' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(62) : error C2601: 'numbers' : local function definitions are illegal C:\Users\Administrator\Desktop\333.cpp(75) : fatal error C1004: unexpected end of file found 执行 cl.exe 时出错.
333.obj - 1 error(s), 0 warning(s) 展开
3个回答
展开全部
主要的错误在于,你定义的函数没有放在主函数前面并且在调用函数时没有声明函数;
建议将所有函数放到主函数前面,或者在主函数前声明这些函数;
void pointcircle(void) {
.......
r1=zx-xx;
r2=zy-yy;
......
}这里能完成转换,这种赋值语句会降低精度。
void pointcircle(void) {
........
printf("在里面")
else if ((r1*r1+r2*r2)==float(rr*rr))
........
}
printf()后面貌似少了个 “;”
主函数少了个 }
哥给你改下吧,以后再也不看这样的代码了:
#include "stdio.h"
void pointcircle(void){
int xx,yy,zx,zy,rr;
float r1,r2;
printf("x,y,x,y,r\n");
scanf("%d,%d,%d,%d,%d",&xx,&yy,&zx, &zy,&rr);
r1=zx-xx;
r2=zy-yy;
if((r1*r1+r2*r2)<(rr*rr))
printf("在里面");
else if ((r1*r1+r2*r2)==float(rr*rr))//继续判断
printf ("On");
else
printf("Out");//完成
}
void pointpoint(void) {
int xx,yy,zx,zy; //创建全局变量来保存 数据
printf ("Please input your own number:坐标1(x,y),坐标2(x,y)?");
scanf("%d,%d,%d,%d",&xx,&yy,&zx,&zy );
if ((xx>zx)&&(yy>zy)) //判断条件
printf("点1优于点2");
else if ((xx<zx)&&(yy<zy))
printf ("点2优于点 1"); //输出
else printf("谁也不优于 谁!");
}
void timetran(void) {
int secs,hour,min,sec; //创建变量
printf ("Please input your own secs!\n");
scanf ("%d",&secs); //输入并赋值给变量
hour=secs/3600; //计算过程
min=(secs/60)-hour*60;
sec=secs%60;
printf ("Now is %d:%2d:%2d ",hour,min,sec); //输出
}
void numbers(void) {
int nub; // 创建变量
printf("Please input your number!");
scanf ("%d",&nub); //输入内容并赋值给变 量
if (nub<10)//判断
printf ("%d is less than 10!",nub);
else if (nub<100)
printf ("%d is less than 100!",nub);
else if (nub<1000 )
printf ("%d is less than 1000!",nub);
else
printf ("%d is more than 1000!",nub); //输出
}
void main (void) {
void pointcircle(void);
void pointpoint(void);
void timetran(void);
void numbers(void);
int select;
printf ("Please choose your own select:\n");
select=getchar();
switch(select){
case 1:pointcircle();
break;
case 2:pointpoint();
break;
case 3:timetran();
break;
case 4:numbers();
break;
default : printf ("Wrong choose!");
}
}
建议将所有函数放到主函数前面,或者在主函数前声明这些函数;
void pointcircle(void) {
.......
r1=zx-xx;
r2=zy-yy;
......
}这里能完成转换,这种赋值语句会降低精度。
void pointcircle(void) {
........
printf("在里面")
else if ((r1*r1+r2*r2)==float(rr*rr))
........
}
printf()后面貌似少了个 “;”
主函数少了个 }
哥给你改下吧,以后再也不看这样的代码了:
#include "stdio.h"
void pointcircle(void){
int xx,yy,zx,zy,rr;
float r1,r2;
printf("x,y,x,y,r\n");
scanf("%d,%d,%d,%d,%d",&xx,&yy,&zx, &zy,&rr);
r1=zx-xx;
r2=zy-yy;
if((r1*r1+r2*r2)<(rr*rr))
printf("在里面");
else if ((r1*r1+r2*r2)==float(rr*rr))//继续判断
printf ("On");
else
printf("Out");//完成
}
void pointpoint(void) {
int xx,yy,zx,zy; //创建全局变量来保存 数据
printf ("Please input your own number:坐标1(x,y),坐标2(x,y)?");
scanf("%d,%d,%d,%d",&xx,&yy,&zx,&zy );
if ((xx>zx)&&(yy>zy)) //判断条件
printf("点1优于点2");
else if ((xx<zx)&&(yy<zy))
printf ("点2优于点 1"); //输出
else printf("谁也不优于 谁!");
}
void timetran(void) {
int secs,hour,min,sec; //创建变量
printf ("Please input your own secs!\n");
scanf ("%d",&secs); //输入并赋值给变量
hour=secs/3600; //计算过程
min=(secs/60)-hour*60;
sec=secs%60;
printf ("Now is %d:%2d:%2d ",hour,min,sec); //输出
}
void numbers(void) {
int nub; // 创建变量
printf("Please input your number!");
scanf ("%d",&nub); //输入内容并赋值给变 量
if (nub<10)//判断
printf ("%d is less than 10!",nub);
else if (nub<100)
printf ("%d is less than 100!",nub);
else if (nub<1000 )
printf ("%d is less than 1000!",nub);
else
printf ("%d is more than 1000!",nub); //输出
}
void main (void) {
void pointcircle(void);
void pointpoint(void);
void timetran(void);
void numbers(void);
int select;
printf ("Please choose your own select:\n");
select=getchar();
switch(select){
case 1:pointcircle();
break;
case 2:pointpoint();
break;
case 3:timetran();
break;
case 4:numbers();
break;
default : printf ("Wrong choose!");
}
}
2012-10-26
展开全部
#include "stdio.h"
void main ()
{
void pointcircle(void);
void pointpoint(void);
void timetran(void);
void numbers(void);
int select;
printf ("Please choose your own select:\n");
select=getchar();
switch(select)
{
case 1:
pointcircle();
break;
case 2:
pointpoint();
break;
case 3:
timetran();
break;
case 4:
numbers();
break;
default :
printf ("Wrong choose!");
}
}
void pointcircle(void)
{
int xx,yy,zx,zy,rr;
float r1,r2; printf("x,y,x,y,r\n");
scanf("%d,%d,%d,%d,%d",&xx,&yy,&zx, &zy,&rr);
r1=zx-xx; r2=zy-yy;
if((r1*r1+r2*r2)<(rr*rr))
printf("在里面");
else if ((r1*r1+r2*r2)==float(rr*rr))
//继续判断
printf ("On");
else printf("Out");//完成
}
void pointpoint(void)
{ int xx,yy,zx,zy;
//创建全局变量来保存 数据
printf ("Please input your own number:坐标1(x,y),坐标2(x,y)?");
scanf("%d,%d,%d,%d",&xx,&yy,&zx,&zy );
if ((xx>zx)&&(yy>zy))//判断条件
printf("点1优于点2");
else if ((xx<zx)&&(yy<zy))
printf ("点2优于点 1");//输出
else printf("谁也不优于 谁!"); }
void timetran(void)
{
int secs,hour,min,sec;//创建变量
printf ("Please input your own secs!\n"); scanf ("%d",&secs);//输入并赋值给变量
hour=secs/3600;//计算过程
min=(secs/60)-hour*60; sec=secs%60; printf ("Now is %d:%2d:%2d ",hour,min,sec);//输出
}
void numbers(void) { int nub;// 创建变量
printf("Please input your number!");
scanf ("%d",&nub);//输入内容并赋值给变 量
if (nub<10)//判断
printf ("%d is less than 10!",nub);
else if (nub<100) printf ("%d is less than 100!",nub);
else if (nub<1000 ) printf ("%d is less than 1000!",nub);
else printf ("%d is more than 1000!",nub);//输出
}
除了我,估计没人愿意改这么烂的代码了。。
void main ()
{
void pointcircle(void);
void pointpoint(void);
void timetran(void);
void numbers(void);
int select;
printf ("Please choose your own select:\n");
select=getchar();
switch(select)
{
case 1:
pointcircle();
break;
case 2:
pointpoint();
break;
case 3:
timetran();
break;
case 4:
numbers();
break;
default :
printf ("Wrong choose!");
}
}
void pointcircle(void)
{
int xx,yy,zx,zy,rr;
float r1,r2; printf("x,y,x,y,r\n");
scanf("%d,%d,%d,%d,%d",&xx,&yy,&zx, &zy,&rr);
r1=zx-xx; r2=zy-yy;
if((r1*r1+r2*r2)<(rr*rr))
printf("在里面");
else if ((r1*r1+r2*r2)==float(rr*rr))
//继续判断
printf ("On");
else printf("Out");//完成
}
void pointpoint(void)
{ int xx,yy,zx,zy;
//创建全局变量来保存 数据
printf ("Please input your own number:坐标1(x,y),坐标2(x,y)?");
scanf("%d,%d,%d,%d",&xx,&yy,&zx,&zy );
if ((xx>zx)&&(yy>zy))//判断条件
printf("点1优于点2");
else if ((xx<zx)&&(yy<zy))
printf ("点2优于点 1");//输出
else printf("谁也不优于 谁!"); }
void timetran(void)
{
int secs,hour,min,sec;//创建变量
printf ("Please input your own secs!\n"); scanf ("%d",&secs);//输入并赋值给变量
hour=secs/3600;//计算过程
min=(secs/60)-hour*60; sec=secs%60; printf ("Now is %d:%2d:%2d ",hour,min,sec);//输出
}
void numbers(void) { int nub;// 创建变量
printf("Please input your number!");
scanf ("%d",&nub);//输入内容并赋值给变 量
if (nub<10)//判断
printf ("%d is less than 10!",nub);
else if (nub<100) printf ("%d is less than 100!",nub);
else if (nub<1000 ) printf ("%d is less than 1000!",nub);
else printf ("%d is more than 1000!",nub);//输出
}
除了我,估计没人愿意改这么烂的代码了。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用手机打了这么多,难为你了。所以printf后没有“;”就原谅你了,其他的就没时间去看了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询