急!!!!c语言问题!!
求助!这个程序的问题差不多都相同,可我找不出为什么会有这些问题,请高手帮帮忙吧!c(57):errorC2143:syntaxerror:missing';'before...
求助!这个程序的问题差不多都相同,可我找不出为什么会有这些问题,请高手帮帮忙吧!
c(57) : error C2143: syntax error : missing ';' before 'type'
c(58) : error C2075: 'c' : array initialization needs curly braces
c(96) : error C2143: syntax error : missing ';' before 'type'
c(99) : error C2065: 'na' : undeclared identifier
c(99) : error C2109: subscript requires array or pointer type
c(99) : error C2106: '=' : left operand must be l-value
c(101) : error C2065: 't' : undeclared identifier
c(101) : error C2106: '=' : left operand must be l-value
c(105) : error C2109: subscript requires array or pointer type
c(105) : warning C4013: 'hanshu3' undefined; assuming extern returning int
#include<stdio.h>
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;}
return n;
}
int hanshu2(double f)
{double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
int hanshu3(double f)
{double bm,k,b0,x,y,x3,y3,c[4]=0,r;
int nm,n=0;
k=tan(f);
b0=0;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
void main()
{double f;
int na[1000],t=0,i,j,z;
na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{na[t]=hanshu3(f);
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{if(na[i]<na[j])
{z=na[i];
na[i]=na[j];
na[j]=z;
}
printf("%d",na[0]);
} 展开
c(57) : error C2143: syntax error : missing ';' before 'type'
c(58) : error C2075: 'c' : array initialization needs curly braces
c(96) : error C2143: syntax error : missing ';' before 'type'
c(99) : error C2065: 'na' : undeclared identifier
c(99) : error C2109: subscript requires array or pointer type
c(99) : error C2106: '=' : left operand must be l-value
c(101) : error C2065: 't' : undeclared identifier
c(101) : error C2106: '=' : left operand must be l-value
c(105) : error C2109: subscript requires array or pointer type
c(105) : warning C4013: 'hanshu3' undefined; assuming extern returning int
#include<stdio.h>
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;}
return n;
}
int hanshu2(double f)
{double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
int hanshu3(double f)
{double bm,k,b0,x,y,x3,y3,c[4]=0,r;
int nm,n=0;
k=tan(f);
b0=0;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
void main()
{double f;
int na[1000],t=0,i,j,z;
na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{na[t]=hanshu3(f);
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{if(na[i]<na[j])
{z=na[i];
na[i]=na[j];
na[j]=z;
}
printf("%d",na[0]);
} 展开
13个回答
推荐于2016-09-27
展开全部
//改了,可以用vc++6.0编译,问题不多,就是有些地方不注意。
#include<stdio.h>
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{
double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{
xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;}
return n;
}
int hanshu2(double f)
{//改了c[4]={0}
double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
}
int hanshu3(double f)
{
double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=0;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{
if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
}
void main()
{
double f;
int na[1000],t=0,i,j,z;
na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{
na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{
na[t]=hanshu3(f);
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{
if(na[i]<na[j])
{
z=na[i];
na[i]=na[j];
na[j]=z;
}
printf("%d",na[0]);
}
}
//有很多括号漏了
#include<stdio.h>
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{
double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{
xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;}
return n;
}
int hanshu2(double f)
{//改了c[4]={0}
double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
}
int hanshu3(double f)
{
double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=0;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{
if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
}
void main()
{
double f;
int na[1000],t=0,i,j,z;
na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{
na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{
na[t]=hanshu3(f);
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{
if(na[i]<na[j])
{
z=na[i];
na[i]=na[j];
na[j]=z;
}
printf("%d",na[0]);
}
}
//有很多括号漏了
参考资料: 自己
展开全部
正确答案!
#include
"stdio.h"
long
int
f(int
year,int
month)
{/*f(年,月)=年-1,如月<3;否则,f(年,月)=年*/
if(month<3)
return
year-1;
else
return
year;
}
long
int
g(int
month)
{/*g(月)=月+13,如月<3;否则,g(月)=月+1*/
if(month<3)
return
month+13;
else
return
month+1;
}
long
int
n(int
year,int
month,int
day)
{
/*N=1461*f(年、月)/4+153*g(月)/5+日*/
return
1461L*f(year,month)/4+153L*g(month)/5+day;
}
int
w(int
year,int
month,int
day)
{
/*w=(N-621049)%7(0<=w<7)*/
return(int)((n(year,month,day)%7-621049L%7+7)%7);
}
int
date[12][6][7];
int
day_tbl[
][12]={{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}};
main()
{int
sw,leap,i,j,k,wd,day;
int
year;/*年*/
char
title[]="SUN
MON
TUE
WED
THU
FRI
SAT";
clrscr();
printf("Please
input
the
year
whose
calendar
you
want
to
know:
");/*输入年*/
scanf("%d%*c",&year);/*输入年份值和掠过值后的回车*/
sw=w(year,1,1);
leap=year%4==0&&year%100||year%400==0;/*判闰年*/
for(i=0;i<12;i++)
for(j=0;j<6;j++)
for(k=0;k<7;k++)
date[i][j][k]=0;/*日期表置0*/
for(i=0;i<12;i++)/*一年十二个月*/
for(wd=0,day=1;day<=day_tbl[leap][i];day++)
{/*将第i+1月的日期填入日期表*/
date[i][wd][sw]=day;
sw=++sw%7;/*每星期七天,以0至6计数*/
if(sw==0)
wd++;/*日期表每七天一行,星期天开始新的一行*/
}
printf("\n|==================The
Calendar
of
Year
%d
=====================|\n|",year);
for(i=0;i<6;i++)
{/*先测算第i+1月和第i+7月的最大星期数*/
for(wd=0,k=0;k<7;k++)/*日期表的第六行有日期,则wd!=0*/
wd+=date[i][5][k]+date[i+6][5][k];
wd=wd?6:5;
printf("%2d
%s
%2d
%s
|\n|",i+1,title,i+7,title);
#include
"stdio.h"
long
int
f(int
year,int
month)
{/*f(年,月)=年-1,如月<3;否则,f(年,月)=年*/
if(month<3)
return
year-1;
else
return
year;
}
long
int
g(int
month)
{/*g(月)=月+13,如月<3;否则,g(月)=月+1*/
if(month<3)
return
month+13;
else
return
month+1;
}
long
int
n(int
year,int
month,int
day)
{
/*N=1461*f(年、月)/4+153*g(月)/5+日*/
return
1461L*f(year,month)/4+153L*g(month)/5+day;
}
int
w(int
year,int
month,int
day)
{
/*w=(N-621049)%7(0<=w<7)*/
return(int)((n(year,month,day)%7-621049L%7+7)%7);
}
int
date[12][6][7];
int
day_tbl[
][12]={{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}};
main()
{int
sw,leap,i,j,k,wd,day;
int
year;/*年*/
char
title[]="SUN
MON
TUE
WED
THU
FRI
SAT";
clrscr();
printf("Please
input
the
year
whose
calendar
you
want
to
know:
");/*输入年*/
scanf("%d%*c",&year);/*输入年份值和掠过值后的回车*/
sw=w(year,1,1);
leap=year%4==0&&year%100||year%400==0;/*判闰年*/
for(i=0;i<12;i++)
for(j=0;j<6;j++)
for(k=0;k<7;k++)
date[i][j][k]=0;/*日期表置0*/
for(i=0;i<12;i++)/*一年十二个月*/
for(wd=0,day=1;day<=day_tbl[leap][i];day++)
{/*将第i+1月的日期填入日期表*/
date[i][wd][sw]=day;
sw=++sw%7;/*每星期七天,以0至6计数*/
if(sw==0)
wd++;/*日期表每七天一行,星期天开始新的一行*/
}
printf("\n|==================The
Calendar
of
Year
%d
=====================|\n|",year);
for(i=0;i<6;i++)
{/*先测算第i+1月和第i+7月的最大星期数*/
for(wd=0,k=0;k<7;k++)/*日期表的第六行有日期,则wd!=0*/
wd+=date[i][5][k]+date[i+6][5][k];
wd=wd?6:5;
printf("%2d
%s
%2d
%s
|\n|",i+1,title,i+7,title);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{
double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{
xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;
}
return n;
}
int hanshu2(double f)
{
double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{
if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
}
return n;
}
int hanshu3(double f)
{
double bm,k,b0,x,y,x3,y3,r;
double c[4]={0,0,0,0};
int nm,n=0;
k=tan(f);
b0=0;
for(int m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(int i=0;i<4;i++)
for(int j=i+1;j<4;j++)
{
if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
}
return n;
}
void main()
{double f;
int na[1000],t=0,i,j,z;
na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{na[t]=hanshu3(double(f));
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{if(na[i]<na[j])
{z=na[i];
na[i]=na[j];
na[j]=z;
}
printf("%d",na[0]);
}
}
你写的格式真的是.....
学C要学会基本的调试 以及错误的 定位和分析啊~ 实际很简单的。
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{
double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{
xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;
}
return n;
}
int hanshu2(double f)
{
double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{
if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
}
return n;
}
int hanshu3(double f)
{
double bm,k,b0,x,y,x3,y3,r;
double c[4]={0,0,0,0};
int nm,n=0;
k=tan(f);
b0=0;
for(int m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{
bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{
c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{
c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{
c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{
for(int i=0;i<4;i++)
for(int j=i+1;j<4;j++)
{
if(c[j]>c[i])
{
r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
}
return n;
}
void main()
{double f;
int na[1000],t=0,i,j,z;
na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{na[t]=hanshu3(double(f));
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{if(na[i]<na[j])
{z=na[i];
na[i]=na[j];
na[j]=z;
}
printf("%d",na[0]);
}
}
你写的格式真的是.....
学C要学会基本的调试 以及错误的 定位和分析啊~ 实际很简单的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;}
return n;
}
int hanshu2(double f)
{double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
int hanshu3(double f)
{double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0;
k=tan(f);
b0=0;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
void main()
{double f;
int na[1000],t=0,i,j,z,na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{na[t]=hanshu3(f);
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{if(na[i]<na[j])
{z=na[i];
na[i]=na[j];
na[j]=z;
}
}
printf("%d",na[0]);
}
#include<math.h>
#define C 30*3.1415926/180
#define A 2.8
#define D 7
#define H 4
#define P 90
#define Q 70
int hanshu1()
{double xm;
int nm,t=1,n=0,m;
for(m=0;m<P/(D+1/2*H);m++)
{xm=m*(D+1.0/2*H);
nm=(int)((Q-(Q*xm)/P)/A);
n+=nm;}
return n;
}
int hanshu2(double f)
{double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0,i,j,m;
k=tan(f);
b0=-k*P;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
int hanshu3(double f)
{double bm,k,b0,x,y,x3,y3,c[4]={0},r;
int nm,n=0;
k=tan(f);
b0=0;
for(m=0;m<=(Q-b0)/((D+H/2)*sqrt(k*k+1));m++)
{bm=b0+m*(D+H/2)*sqrt(k*k+1);
x=-(bm/k);
y=bm;
x3=(P*Q-bm*P)/(Q+k*P);
y3=(k*P*Q+bm*Q)/(k*P+Q);
if(x>0&&x<P&&y>0&&y<Q)
{c[0]=bm*tan(C+f)/k;
c[1]=bm;
}
else if((x>P&&y>0&&y<Q)||(x<0&&y>0&&y<Q))
{c[0]=bm;
c[1]=y3-x3*tan(C+f);
}
else if((x>0&&x<P&&y>Q)||(x>0&&x<P&&y<0))
{c[0]=bm*tan(C+f)/k;
c[1]=y3-x3*tan(C+f);
}
if(m>0)
{for(i=0;i<4;i++)
for(j=i+1;j<4;j++)
{if(c[j]>c[i])
{r=c[i];
c[i]=c[j];
c[j]=r;
}
nm=(int)((c[0]-c[1])*cos(C+f)/A);
}
c[2]=c[0];
c[3]=c[1];
n+=nm;
}
return n;
}
void main()
{double f;
int na[1000],t=0,i,j,z,na[0]=hanshu1();
for(f=0;f<90;f=f+1)
{na[t]=hanshu2(f);
t++;
}
for(f=180;f>90;f=f-1)
{na[t]=hanshu3(f);
t++;
}
for(i=0;i<t;i++)
for(j=i+1;j<t;j++)
{if(na[i]<na[j])
{z=na[i];
na[i]=na[j];
na[j]=z;
}
}
printf("%d",na[0]);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stido.h>
main()
{int
year,leap;
scanf("%d",&year);/*输入年份*/
if(year%4==0)/*判断是否被4整除*/
{if(year%100==0))/*判断是否被100整除*/
{if(year%400==0))/*判断是否被400整除*/
leap=1;
else
leap=0;
}
else
leap=1;
}
else
leap=0;
if(leap))/*判断leap是否是真*/
printf("%d
is
a
leap
year");
else
printf("%d
is
not
a
leap
year");/*输出结果*/
}
下面是思路图(书上)
main()
{int
year,leap;
scanf("%d",&year);/*输入年份*/
if(year%4==0)/*判断是否被4整除*/
{if(year%100==0))/*判断是否被100整除*/
{if(year%400==0))/*判断是否被400整除*/
leap=1;
else
leap=0;
}
else
leap=1;
}
else
leap=0;
if(leap))/*判断leap是否是真*/
printf("%d
is
a
leap
year");
else
printf("%d
is
not
a
leap
year");/*输出结果*/
}
下面是思路图(书上)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询