Home > Back-end >  What's the problem with this code, please? Why are there no output?
What's the problem with this code, please? Why are there no output?

Time:04-05

#include
#include
Long long int array [1000]={0};
Int main ()
{
Long long int N;
The scanf (" % LLD, & amp; N);
for(int i=0; i<=N; I++)
{
For (int m=N; M> 0; M -)
{
If (m % I==0)
Array [m] + +;
}
}
for(int i=0; i<=N; I++)
{
Printf (" % d \ n ", array [I]);
}
return 0;
}

CodePudding user response:

More problems, didn't understand what your code to achieve, for reference:
 # include & lt; stdio.h> 
#include
Long int array [1000]={0};//this array capacity is 1000, the subscript 0-999
Int main ()
{
Long int N;
The scanf (" % LLD, & amp; N);//here if N is 11 digits
For (long int I=1; i<=N; I++)//for (int I=0; i<=N; I++)
{
For (long int m=N; M>=0; M -)//appropriate for plastic variable and N in () to the same type, have the assignment m=N
{
If (m % I==0)//first for I can't start from 0 () loop, here the m % 0
Array [m] + +;//array subscript is crossing the line here, because m=N=11 digits
}
}
For (long int I=0; i<=N; I++)
{
Printf (" % d \ n ", array [I]);
}

return 0;
}
  • Related