Home > Back-end >  The great spirit consult
The great spirit consult

Time:09-22

Ask you a great god why this error!





Int main (void)
{
Int a=0;//the number of
Printf (" please input the number of arbitrary \ n ");
The scanf (" % d ", & amp; A);
Int n [a];
int k=0;//brackets
Printf (" please enter any score \ n ");//printf () is the output function, the scanf () is the input function
For (k=0; K<=(a - 1); K++)
{
The scanf (" % d ", & amp; N [k]);//the scanf () in the parameter list notice "& amp;"
}
For (k=0; k<=(a - 1); K++)
{

If (n [K] <0 | | n [K] & gt; 100)//ruled out less than zero or greater than 100
Printf (" input points wrong \ n ");
Else if (n [K] Printf (" E \ n ");
Else if (n [K] <=69)//59 & lt; N & lt;=69
Printf (" D \ n ");
Else if (n [K] <=79)/69 & lt; N & lt;=79
Printf (" C \ n ");
Else if (n [K] <=89)/79 & lt; N & lt;=89
Printf (" \ n B ");
Else if (n [K] <=100)/89 & lt; N & lt;=100
Printf (" A \ n ");
}
return 0;
}

CodePudding user response:

What's wrong? Compile or run wrong?

CodePudding user response:

Int n [a]; -- -- -- -- -- -- -- -- -- -- - is wrong here? Data statement with a constant, cannot use the variable a

CodePudding user response:

Int n [a];=="" c language does not support this definition array, a is a constant value,

CodePudding user response:

The
refer to the original poster qiang road response:
ask everyone a great god why this error!





Int main (void)
{
Int a=0;//the number of
Printf (" please input the number of arbitrary \ n ");
The scanf (" % d ", & amp; A);
Int n [a];
int k=0;//brackets
Printf (" please enter any score \ n ");//printf () is the output function, the scanf () is the input function
For (k=0; k<=(a - 1); K++)
{
The scanf (" % d ", & amp; N [k]);//the scanf () in the parameter list notice "& amp;"
}
For (k=0; k<=(a - 1); K++)
{

If (n [K] <0 | | n [K] & gt; 100)//ruled out less than zero or greater than 100
Printf (" input points wrong \ n ");
Else if (n [K] Printf (" E \ n ");
Else if (n [K] <=69)//59 & lt; N & lt;=69
Printf (" D \ n ");
Else if (n [K] <=79)/69 & lt; N & lt;=79
Printf (" C \ n ");
Else if (n [K] <=89)/79 & lt; N & lt;=89
Printf (" \ n B ");
Else if (n [K] <=100)/89 & lt; N & lt;=100
Printf (" A \ n ");
}
return 0;
}

Change of K to K should be good

CodePudding user response:

Upstairs positive solution, the problem should be mainly on your variable names, with have a k is defined above, the following is not used to define the k, your program error should be submitted to the which line k didn't define?

CodePudding user response:



The figure of a, K (in capital have the) change

I am using vs2019, the scanf to scanf_s (like starts from the vs2017), not need not tube,

CodePudding user response:


Finally put the wrong picture
  • Related