Home > Back-end >  Multiple of 3
Multiple of 3

Time:10-03

Don't know why I didn't pass the

CodePudding user response:

Some compilers do not support with variable definition array length
Into a dynamic application memory

CodePudding user response:

You're an error, how don't quote what wrong post?

CodePudding user response:

Did you note the title allows you to pay attention to the value range
A maximum of 10 1000
Write up behind is 1 1000 0
How could the int the deposit

CodePudding user response:

(1) the dimension of the array elements must be constant

(2) is beyond the scope of the int

CodePudding user response:

Array length needs to be fixed, and can't be a variable-length, suggest using int * a=(int *) malloc (sizeof (int) * t); In place of int a [t];

CodePudding user response:

Positive solution proposal application memory upstairs

CodePudding user response:

Want to use a variable length arrays, the fifth floor positive solution, but remember free after using it

CodePudding user response:

The main problem here should not be the compiler doesn't support variable-length arrays, but the range of int array can't store a maximum of 10 1000, to build an array of words, so it is to establish an int a [t] [1001] such an array, or use malloc create a 2 d array,
Then use an array to store a maximum of 10 1000 such large Numbers, by judging whether each digit and can be divided exactly by 3 to determine whether the number can be divided exactly by 3,
  • Related