Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "vetores.h"
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- void ExibeVetor(VETOR &v, int n){
- for (int i = 0; i < n; i++)
- cout << v[i] << '\t';
- cout << endl;
- }
- /* vai gerar um número randomico entre 'min' e 'max' */
- unsigned int randomico( unsigned int min, unsigned int max ){
- double escala = ( double )rand()/RAND_MAX;
- return ( max - min + 1 ) * escala + min;
- }
- void sortear (VETOR &v, int n){ //sortear valores entre 30 e 100
- for (int i = 0; i < n; i++)
- v[i] = randomico( 30, 100 );
- }
- int mediaPares(VETOR &v, int n){ //media dos componentes pares
- int s = 0; int media, pares = 0;
- for(int i = 0; i < n;i++){
- if(v[i]%2==0){
- pares++;
- s+=v[i];
- }
- }
- media = s/pares;
- return media;
- }
- int quantImpares (VETOR &v, int n){ //contar os impares
- int q=0;
- for (int i = 0; i < n; i++)
- if (v[i]% 2 != 0) q++;
- return q;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement