daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Feb 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4. #define m 5
  5.  
  6.   int i;
  7. //adicionar elementos
  8. void list_add(int *v);
  9. //mudar ordem dos elementos
  10. int change_elements(int x, int *v);
  11.  
  12. int main(){
  13.     int *l1;
  14.     int num;
  15.     //alocação dinamica
  16.     l1 = malloc (m * sizeof (int *));
  17.     list_add(l1);
  18.     change_elements(num,l1);
  19.  
  20. }
  21. void list_add(int *v){
  22.  
  23.     for(i=0;i<m;i++){
  24.     printf("\nPreencha a lista: "); scanf("%d",&v[i]);
  25.     }
  26. }
  27. int change_elements(int x, int *v){
  28.     int aux, j;
  29.     printf("Quantos valores quer trocar?: "); scanf("%d",&x);
  30.     j = 0;
  31.     for(i=0;i<x;i++){
  32.       aux = v[i];
  33.       v[m-j] = aux;
  34.       j++;
  35.     }
  36.     for(i=0;i<m;i++){
  37.     printf("\nNova lista: %d ",v[i]);
  38. }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top