punteros en lenguaje c

Anonymous
2020-10-12T03:59:37.41+00:00

hola.tengo una duda con la creación de un código, en el que debo crear una función de tipo arreglo, que pida por consola n veces los valores de cada arreglo y que luego estos se desordenen.
TODO ESTO EN LENGUAJE C.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,683 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Guido Franzke 2,196 Reputation points
    2020-10-12T06:09:42.77+00:00

    Translated with Google:
    hello. I have a doubt with the creation of a code, in which I must create a function of type arrangement, which asks the console n times for the values of each arrangement and then they get out of order.
    ALL THIS IN C LANGUAGE

    -> This looks like homework. Show us what you implemented so far. We will help you with your code and logics.
    So far, I would help you this way. This could be one general algorithm: define the type, in main define an array a of that type, input n, loop n-times to input the values a[i]. What do you mean with "they get out of order"? If you want to show the array, loop n-times over the array and cout a[i].

    Regards, Guido


  2. Guido Franzke 2,196 Reputation points
    2020-10-13T05:57:44.757+00:00
    #include <stdio.h>
    #include <stdlib.h>
    
    void crearArregVal(int* a, const int n)
    {
      for (int i = 0; i < n; ++i)
      {
         printf("Ingrese el valor del arreglo[%i]\n",i); 
         // fflush(stdin); 
         scanf("%d", a + i);
      }
      //...
    }
    
    // call it:
    int values[20];
    crearArregVal(values, 20);
    

    Regards, Guido

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.