Home > Back-end >  For help about c language output not assigned a value of array elements
For help about c language output not assigned a value of array elements

Time:09-17

Suppose I defines an array a [10], and then I put the number of elements in the inside can be between 1-10, so when I want to be the output statements should be how to write can only will have the assignment of elements shows that without the assignment of array elements don't show?

CodePudding user response:

You can determine the array element is null is not null, you output again

CodePudding user response:

You can initialize a particular impossible assignment value as the initial value, the output is not only for the value of data

CodePudding user response:

To see what kind of data is that you put in it? Is greater than 0 data such as put in, you can put the array initialized to 0, and then put it in, the final output, output only non-zero value,
Can also define an array, used to hold the assignment of the array subscript, so according to the output that is assigned a value assignment subscripting,

Can you understand these two methods?

CodePudding user response:

Method a, to initialize an array impossible value, an effective data to judgment,
Method 2, the use of another array, to mark the corresponding data whether early assignment,
Method 3, the use of structure, a stored data effectively, a used to mark is assigned, the final definition structure arrays, specific what kind of method is used according to actual condition decision,

CodePudding user response:

Several, put in the time of counting the loop to a few, not output, estimates that your request is not that complicated
  • Related