我要疯了,高手帮忙来看看,之前一直在用的变量,突然之间就说我没定义过,不给编译了呢
#include <stdio.h>#include <math.h>
int numbera,numberb;
int a,line,i;
int c,d; //line counter use to different lines
int e=2,f=2; //let two line have same value
int counterspace,counternum; // counter the space in result
int numberrow=0;
int numberbasic=10;
int result;
void print_eline1() //+--------------------+
{
if(a!=0) //first bar underline
{
printf("+");
}
for(a=0;a<(2*numbera-1)*d;a++) // space
{
printf(" ");
}
printf("+");
for(a=0;a<2*numbera-1;a++)
{
printf("-");
}
printf("+");
for(a=0;a<19-2*numbera;a++)
{
printf("-");
}
printf("+");
for(a=0;a<2*numbera-1;a++)
{
printf("-");
}
printf("+\n");
}
void print_eline2() //+--------------------+
{
if(a!=0) //first bar underline
{
printf("+");
}
for(a=0;a<2*numbera*e-1;a++) // space
{
printf(" ");
}
printf("+");
for(a=0;a<2*numbera-1;a++)
{
printf("-");
}
printf("+");
for(a=0;a<19-2*numbera;a++)
{
printf("-");
}
printf("+");
for(a=0;a<2*numbera-1;a++)
{
printf("-");
}
e=e+1;
printf("+\n");
}
void print_oline1() //|0 1 2 3 4 5 6 7 8 9|
{
if ((line!=1)&&(line!=20)) //no | for first and taget line
{
printf("|");
}
for(a=0;a<(2*numbera-1)*c;a++)
{
printf(" ");
}
printf("|0");
for(i=1;i<numberbasic;i++)
{
printf(" %d",i);
}
printf("|\n");
}
void print_oline2() //|0 1 2 3 4 5 6 7 8 9|
{
if ((line!=1)&&(line!=20)) //no | for first and taget line
{
printf("|");
}
for(a=0;a<(2*numbera)*f-1;a++)
{
printf(" ");
}
counterspace=a;
printf("|0");
for(i=1;i<numberbasic;i++)
{
printf(" %d",i);
}
printf("|\n");
f=f+1;
}
int main (void)
{
printf ("a\n");
scanf ("%d",&numbera);
printf ("b\n");
scanf ("%d",&numberb);
for(line=0;line<=numberb*2-1;line++) //for line number
{
c=line/2;
d=c-1;
if(line%2==0) //even line
{
printf("+-");
if ((line!=0)&&(line!=20)) //not for first and taget line
{
if(line<=4)
{
print_eline1();
}
else
{
print_eline2();
}
}
else //for first and taget line
{
printf("+");
for(i=1;i<=2*numberbasic-1;i++)
{
printf("-");
}
printf("+\n");
}
}
else //ODD
{
printf("|%d",numberrow);
if(line<=4)
{
print_oline1();
}
else
{
print_oline2();
}
numberrow=numberrow+1;
}
}
printf("+-+");
for(a=1;a<=(counterspace+1)/20;a++) //result +----+ //+1 only for some special numbers e.g.6*6,5*5
{
for(i=0;i<=18;i++)
{
printf("-");
}
counternum=a;
printf("+");
}
for(a=0;a<counterspace-counternum*20;a++)
{
printf("-");
}
printf("+");
result=counterspace-counternum*20;
printf("s %d n %d r %d",counterspace,counternum,result);
/*
for(a=0;a<20-2*numbera-1;a++)
{
printf("-");
}
printf("+");
for(a=0;a<19;a++)
{
printf("-");
}*/
printf("+\n");
//result number
printf("|%d",numberrow);
for(a=0;a<=(result+21)/20;a++)
{
printf("|0");
for(i=1;i<numberbasic;i++)
{
printf(" %d",i);
}
}
printf("|");
printf("\n");
以上的都是好好的。
我只是想在中间查入一条
if(counterspace==39)
{
counterspace=counterspace+1;
}
gcc的时候就老是说我这行的counterspaced没有定义过。怎么回事啊?请高手指教。