Essays.club - TCC, Modelos de monografias, Trabalhos de universidades, Ensaios, Bibliografias
Pesquisar

Exercícios de Computação: Algoritmos e Programação II

Por:   •  17/10/2017  •  784 Palavras (4 Páginas)  •  421 Visualizações

Página 1 de 4

...

int n, a, b;

n = Dimensao();

LeVetor(v, n);

cout

cout

MaiorMenor(v, n, a, b);

cout

cout

cout

DobraVetor(v, n);

cout

ExibeVetor(v, n);

system("pause");

return 0;

}

Exercício 15.4:

Vetores.h

#ifndef VETORES_H

#define VETORES_H

const int Max = 40;

typedef int Vetor[Max];

int Dimensao();

void Sortear(Vetor &v, int n);

int MediaPar(Vetor &v, int n);

int Impares(Vetor &v, int n);

#endif

Vetores.cpp

#include "Vetores.h"

#include

#include

#include

#include

using namespace std;

int Dimensao(){

int n;

cout > n;

while(n Max){

cout

cout > n;

}

return n;

}

void Sortear(Vetor &v, int n){

srand(time(0));

for(int i = 0; i

v[i]= rand() % 50 - 1;

cout

}

}

int MediaPar(Vetor &v, int n){

int c = 0;

int m;

int s = 0;

for(int i = 0; i

if(v[i]%2 == 0){

s = s + v[i];

c++;}

}

m = s/c;

return m;

}

int Impares(Vetor &v, int n){

int p = 0;

for(int i = 0; i

if(v[i]%2 != 0)

p++;}

return p;

}

mainVetores.cpp

#include

#include

#include

#include

#include

#include "Vetores.h"

using namespace std;

int main(int argc, char** argv)

{

Vetor v;

int n;

n = Dimensao();

cout

Sortear(v, n);

cout

cout

system("pause");

return 0;

}

Exercício 15.3:

Vetores.h

#ifndef VETORES_H

#define VETORES_H

const int Max = 50;

typedef double Vetor[Max];

int Dimensao();

void Componentes(Vetor &v, int n);

double Media(Vetor &v, int n);

double Porcentagem(Vetor &v, int n);

#endif

Vetores.cpp

#include "Vetores.h"

#include

#include

#include

using namespace std;

int Dimensao(){

int n;

cout > n;

while(n Max){

cout

cout > n;

}

return n;

}

void Componentes(Vetor &v, int n){

for(int i = 0; i

v[i]= sin(i)/cos(i);

cout

}

}

...

Baixar como  txt (7.8 Kb)   pdf (91.4 Kb)   docx (21.5 Kb)  
Continuar por mais 3 páginas »
Disponível apenas no Essays.club