TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Lista de vetores

Por:   •  18/6/2015  •  Pesquisas Acadêmicas  •  667 Palavras (3 Páginas)  •  255 Visualizações

Página 1 de 3

ALUNA: HELENA NIEDERAUER DA SILVA TAVARES

PROFESSOR: LEANDRO

LISTA DE VETORES

01) 

#include

#include

main()

{

int x, y, qtd = 0;

float valores[100];

for(x = 1; x <= 100; x++)

{

printf("Valor %x: ", x);

scanf("%f", &valores[x]);

if(valores[x] > 4.0 && valores[x] < 7.0)

{

qtd++;

}

}

printf("\nNumeros entre 4.0 e 7.0: %d", qtd);

getch () ;

}

02)

#include

#include

main()

{

int j;

float elementos[50], maior = 0;

for(j = 1; j <= 50; j++)

{

printf("Valor %j: ", j);

scanf("%f", &elementos[j]);

if(elementos[j] > maior)

{

maior = elementos[j];

}

}

printf("\nMaior valor digitado: %f", maior);

getch () ;

}

03)

#include

#include

main ()

{

int j;

float elementos[50], maior = 0, segundo = 0;

for(j = 1; j <= 50; j++)

{

printf("Valor %j: ", j);

scanf("%f", &elementos[j]);

if (elementos[j] > maior)

 {

segundo = maior;

maior = elementos[j];

} else if (elementos[j] > segundo && elementos[j]!= maior)

{

segundo = elementos[j];

}

}

printf("\nMaior: %f", maior);

printf("\nSegundo Maior: %f", segundo);

getch();

}

04)

#include

#include

main ()

{

// DECLARAÇÃO DE VARIÁVEIS

int n, i, j, comp, conta, vezes;

float seq[500];

// SOLICITA QUANTIDADE DE NÚMERO PARA A SEQUÊNCIA

printf("Numero de elementos da sequencia: ");

scanf("%d", &n);

// LÊ SEQUÊNCIA

printf("Digite uma sequencia de %d numeros reais: \n", n);

for(i = 0; i < n; i++)

{

scanf("%f", &seq[i]);

}

// VERIFICA QUANTAS VEZES CADA NÚMERO APARECE NO VETOR DA SEQUÊNCIA

for(i = 0; i < n; i++)

 {

vezes = 1;

j = i + 1;

while (j < n)

{

// SE O NÚMERO E O PRÓXIMO FOREM DIFERENTES

if(seq[j] != seq[i])

{

j++;

}

else

{

// SE FOREM IGUAIS CONTA UMA VEZ

vezes++;

n--;

seq[j] = seq[n];

}

}

printf("\n %f ocorreu %d vezes", seq[i], vezes);

}

getch () ;

}

05)

#include

#include

main ()

{

int i, n;

float prod, x[500], y[500];

printf("Digite o tamanho dos vetores: ");

scanf("%d", &n);

printf("\nDigite os componentes do vetor x: \n");

for (i = 0; i < n; i++)

{

scanf("%f", &x[i]);

}

printf("\nDigite os componentes do vetor y: \n");

for (i = 0; i < n; i++)

{

scanf("%f", &y[i]);

}

prod = 0;

for (i = 0; i < n; i++){

prod = prod + x[i] * y[i];

...

Baixar como (para membros premium)  txt (3.4 Kb)   pdf (54.9 Kb)   docx (175.9 Kb)  
Continuar por mais 2 páginas »
Disponível apenas no TrabalhosGratuitos.com