SHARE
TWEET

Untitled

a guest May 16th, 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.  
  5.  
  6. void cubos(int *vector);
  7. int pares(int *vector);
  8.  
  9. void cubos(int *vector){
  10.     int i = 0;
  11.     int impares = 1;
  12.     int end = 0;
  13.     while(end == 0){
  14.         if(impares%2 == 1){
  15.             *(vector+i) = pow(impares,3);
  16.             i++;
  17.         }
  18.  
  19.         impares++;
  20.         if(i>=1000){
  21.             end =1;
  22.         }
  23.     }
  24. }
  25.  
  26.  
  27. int pares(int *vector){
  28.     int pares = 0;
  29.     for(int i = 0; i<1000; i++){
  30.         if(*(vector+i)%2 == 0){
  31.             pares++;
  32.         }
  33.     }
  34.     return pares;
  35. }
  36.  
  37.  
  38. int main(){
  39.     int *vector;
  40.     int numpares;
  41.     vector = (int *)malloc(sizeof(int)*1000);
  42.     cubos(vector);
  43.     numpares = pares(vector);
  44.     printf("Hay %d numeros pares en el vector.\n",numpares);
  45.     for(int i=0;i<1000;i++){
  46.         printf("%d\t", *(vector+i));
  47.     }
  48.     printf("\n");
  49.     return 0;
  50. }
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