Home > Back-end >  C language programming online segment error is how to return a responsibility
C language programming online segment error is how to return a responsibility

Time:10-07

Operation result is correct, no array subscript crossing the line, but is always wrong

CodePudding user response:

Post code and title

CodePudding user response:

May be caused by array is too big, such as:
Int a, [10000000000].

CodePudding user response:


#include
#include
#include

Int main ()
{
Char nums [60].
Char index [30].
int j=0;//j digital length
Int k=0;//integer array counter
int temp;
Int answers [30];//final answer

Int m=0;
Gets (nums);
for(int i=0; i<59 & amp; & Nums [I]!='\ 0'; I++ j++)
{
M=0;
If (nums [I]==' ')
{
for(; M{
The index [m]=nums (I - j + m),
}
The index [m]='\ 0';

Temp=atoi (index);
Answers [k]=temp;
K++;//
J=1;
}//if
If (nums [I + 1)=='\ 0')
{
i=i+1;
for(; M<=j; M++)
{
The index [m]=nums [I - j - 1 + m);
}
The index [m]='\ 0';

Temp=atoi (index);
Answers [k]=temp;
K++;

break;
}//if
}//for

For (int s=0; S{
If (answers [s + 1)==0)
Answers [s]=answers [s + 1)=0;
The else
{
Answers [s] *=answers [s + 1];
Answers [s + 1] --;
}
}//for

For (int s=0; S{
If (answers [s + 1]!=0 & amp; & Answers [s].=0)
{
If (s + 1==k)
Printf (" % d % d ", answers [s], answers/s + 1);
The else
Printf (" % d % d ", answers [s], answers/s + 1);
}
The else
{
If (answers==0) [s + 1] {printf (" % d % d ", answers [s], answers/s + 1); break; }
}
}//for
return 0;
}


CodePudding user response:

refer to the second floor proorck2019 response:
may be caused by array is too big, such as:
Int a, [10000000000].

The title and code is on the third floor

CodePudding user response:

Fun
reference 1 floor response:
post code and title

The title and code to see the third floor

CodePudding user response:

Look at the input description
Coefficient and index is the absolute value of no more than 1000, what this means?
That is to say, the polynomial May 1001, index from 1000 to 0
some situationCoefficient absolute value is not more than 1000, with the sign bit coefficient of the five most
So the expression may be 998-1000, 1000-1000, 999-1000... - 1000 0 0 0
Can you figure out how long is the string, not crossing the line?
Your Numbers, index, open answer array is too small

CodePudding user response:

Fun
reference 6 floor response:
watch carefully the input description
Coefficient and index is the absolute value of no more than 1000, what this means?
That is to say, the polynomial May 1001, index from 1000 to 0
some situationCoefficient absolute value is not more than 1000, with the sign bit coefficient of the five most
So the expression may be 998-1000, 1000-1000, 999-1000... - 1000 0 0 0
Can you figure out how long is the string, not crossing the line?
Your Numbers, index, answer the array open small

Thank you for your answer, the problem has been solved
  • Related