Query a one dimensional array for the existence of a specified element. Column 2 4 6 0, 1,4 Input 6,

Updated on technology 2024-04-03
3 answers
  1. Anonymous users2024-02-07

    #include

    int find(int a,int s,int n,int j)int i ;

    for(i=s;iif(a[i]==j)

    return (i+1);

    return 0;

    int main()

    int a[10],n=5,j,s,i;

    printf("Please enter a[10]:");

    for(i=0;i<10;i++)

    scanf("%d",&a[i]);

    printf("Please enter the number you want to find");

    scanf("%d",&j);

    s=find(a,0,n,j);

    if(s)else

    printf("There is no such number in the array");

  2. Anonymous users2024-02-06

    #include

    void main(),i,bflage=0,find;

    printf("Please enter the number you are looking for:");

    scanf("%d",&find);

    for(i=0;iif(find==num[i]){

    bflage=1;

    printf("The subscript of the array corresponding to %d is: %d!",find,i);

    if(bflage==0){

    printf("Sorry, no corresponding element found! ");

    printf("");

  3. Anonymous users2024-02-05

    Summary. Hello dear! Glad to answer for you, C++ enters a two-dimensional array and finds all array elements less than 0 and the row and column subscripts they are in.

    Here you need to use a pointer, you can use the address method (a[i]+j like this) or pointer (ptr + + like this) to input and output the elements of the two-dimensional array, and then sum the minimum value Assuming that the two-dimensional array is subscripted with 0 element is the smallest and points to the element with a pointer, the subsequent elements are compared with it, if there is a smaller one, then replace Then output its value and the corresponding pointer The address pointed by the pointer is the address of its subscript, I hope to help you!

    C++ enters a two-dimensional array and finds all array elements less than 0 and the row and column subscripts in which they are located.

    Hello dear! Glad to answer for you, C++ input a two-dimensional array, find out all the array elements less than 0 and the row and column subscripts where they are needed here need to use a pointer, you can use the address mountain modulo method (a[i]+j like this) or pointer (ptr++ like this) to input and output the elements of the two-dimensional array, and then sum the minimum value Assuming that the element with the subscript 0 of the two-dimensional array is the smallest and points to the element with a pointer, the subsequent elements are compared with it, and if there is a smaller teasing, it is replaced Then output its value and the corresponding pointer The address of the pointer is the address of its subscript, and Youpei hopes to help you!

    Ask about custom messages].

Related questions
11 answers2024-04-03

Are you going to write to a file or to read?

11 answers2024-04-03

The method for dynamically defining a 2-dimensional array in C++ is: >>>More

7 answers2024-04-03

1 Maximum number of subscript elements - 1

2 Precautions for use: >>>More

20 answers2024-04-03

In fact, if you have read "C Expert Programming", it is very simple, and this problem has been carefully described above. It's stored in memory as shown in the figure. n[0][5] is actually *(*n+0)+5), which is the sixth cell. >>>More

5 answers2024-04-03

According to the time condition, the first 10 and the last 10 are selected. >>>More