I early at the beginning of the c language is a beginner, you help to look at, don't use too advanced function, syntax,
Main card in the input n don't know how to stop,
CodePudding user response:
You input n first, reoccupy cycle to store an array that n number, the end of the cycle is finished input, and then traversal cycle can find that number does not exist
CodePudding user response:
With an array, with chain table is easy to implement, you is at the beginning of the array of theory,
CodePudding user response:
The problem is how to let the end of the cycle
CodePudding user response:
Can the malloc
# include
Int n, * p; The scanf (" % d ", & amp; n); P=(int *) malloc (sizeof (int) * n); . free(p); CodePudding user response:
reference Tlouer_Elle reply: 3/f the problem is how to let the end of the cycle Use an array to store the number n, array is fixed length, from the array, in turn, to find, if found deleted, if the array cycle until the last place, has not yet found, end of the cycle, Such as define array int a [10], then loop through for(int i=0; i<10; I++) { If (a==[I] what do you want to find the value of the) } CodePudding user response:
The references 4 floor? Victor.?? Response: can malloc # include Int n, * p; The scanf (" % d ", & amp; n); P=(int *) malloc (sizeof (int) * n); . free(p); What you said is too advanced beginner hasn't learned you say this CodePudding user response:
5250 references 5 floor response: Quote: refer to the third floor Tlouer_Elle response: The problem is how to let the end of the cycle Use an array to store the number n, array is fixed length, from the array, in turn, to find, if found deleted, if the array cycle until the last place, has not yet found, end of the cycle, Such as define array int a [10], then loop through for(int i=0; i<10; I++) { If (a==[I] what do you want to find the value of the) } Mainly n I don't know the number 10 is not necessarily array I just want to use an array to save CodePudding user response:
reference 1st floor QPFXGG response: you input n first, reoccupy cycle to store an array n Numbers, this end of the cycle is finished input, and then traversal cycle can locate the number does not exist You can write as simple as possible some come out to me see CodePudding user response:
refer to 6th floor Tlouer_Elle response: Quote: reference 4 floor? Victor.?? Response: Can the malloc # include Int n, * p; The scanf (" % d ", & amp; n); P=(int *) malloc (sizeof (int) * n); . free(p); What you said is too advanced beginner said you haven't learned the This is the way to create a variable-length array, you should immediately CodePudding user response:
Like this word input always could not be infinite you define a slightly larger array, 100, 1000 CodePudding user response:
refer to the eighth floor Tlouer_Elle response: Quote: refer to 1st floor QPFXGG response: You input n first, reoccupy cycle to store an array that n number, the end of the cycle is finished input, and then traversal cycle can find the number of don't exist You can write I see it as simple as possible some out # include Int main () { Int n, f [100], x, I, j; The scanf (" % d % d ", & amp; N, & amp; X);//n number, the number of x is to find the for(i=1; i<=n; I++) { The scanf (" % d ", & amp; F [I]); } for(i=1; i<=n; I++) { If (x==f [I]) { //instructions found For (j=I; j<=n - 1; J++) F=f [j] [j + 1); break; } } If (I==n + 1) { //that can't find the Printf (" the number does not exist "); } The else { for(i=1; i Printf (" % d ", f [I]); } return 0; } CodePudding user response:
The references 9 floor? Victor.?? Response: Quote: refer to the sixth floor Tlouer_Elle response: The Quote: reference 4 floor? Victor.?? Response: Can the malloc # include Int n, * p; The scanf (" % d ", & amp; n); P=(int *) malloc (sizeof (int) * n); . free(p); What you said is too advanced beginner said you haven't learned the This is the way to create a variable-length array, you should immediately learned Teachers don't class, homework to finish CodePudding user response:
The refer to 12 floor Tlouer_Elle reply: Quote: references 9 floor? Victor.?? Response: Quote: refer to the sixth floor Tlouer_Elle response: The Quote: reference 4 floor? Victor.?? Response: Can the malloc # include Int n, * p; The scanf (" % d ", & amp; n); P=(int *) malloc (sizeof (int) * n); . free(p); What you said is too advanced beginner said you haven't learned the This is the way to create a variable-length array, you should immediately learned Teachers don't class, homework to finish So now worry Worry if I help you wrote