Advertisement
MarceloSousa

Atividade 2 sandro

Nov 19th, 2013
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4. #include <time.h>
  5.  
  6. calculo(int *,int);
  7.  
  8. int main (void){
  9. int i,num[20],oc=0,resposta=0;
  10.  
  11. srand(time(NULL));
  12.     for(i=1;i<20;i++){
  13.  
  14.         num[i]=1+(rand()%15);
  15.         //printf("num: %d\n",num[i]);}
  16.  
  17.     printf("Digite o Numero de Ocorrência: ");
  18.     scanf("%i",&oc);
  19.  
  20.     resposta=calculo(num,oc);
  21.     printf("Resposta: %i",resposta);
  22.  
  23. getch();
  24. return 0;}
  25.  
  26. int calculo(int *numero,int flag){
  27.     int i,resp=0;
  28.     for(i=1;i<20;i++){
  29.         if(numero[i]==flag)
  30.             resp++;}
  31.  
  32. return resp;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement