Académique Documents
Professionnel Documents
Culture Documents
MATRICULA: 200506733
RESPOSTA:
#include <stdio.h>
main() {
int vetor[] = {10, 2, 4, 5, 30};
int tamanho = 5;
int indice;
system("pause");
}
2. Escreva um programa que a partir de um cadeia de caractere definida como
{‘a’, ‘v’, ‘a’, ‘l’, ‘i’, ‘a’, ‘c’, ‘a’, ‘o’}, imprima em sua ordem de definição e na
ordem inversa de definição.
RESPOSTA:
#include <stdio.h>
main() {
char vetor[] = {'a', 'v', 'a', 'l', 'i', 'a', 'c', 'a', 'o'};
char tamanho = 9;
char indice;
for (indice = 0; indice < tamanho; indice++) {
printf("%c ", vetor[indice]);
}
printf("\n");
for (indice = tamanho-1; indice >= 0; indice--) {
printf("%c ", vetor[indice]);
}
printf("\n");
system("pause");
}
3. Escreva um programa que leia 10 valores floats e os armazene em um vetor.
Depois calcule e imprima a média, o desvio padrão e a mediana destes
valores.
RESPOSTA:
#include <stdio.h>
main(){
int tamanho=10;
int indice=0;
float vetor[tamanho], var[tamanho], somavar=0, raiz, desv;
RESPOSTA:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main(){
int let1[26],let2[26], y, i;
char c;
int igual=1;
for(i=0;i<26;i++) let1[i]=let2[i]=0;
printf("DIGITE A PRIMEIRA CADEIA DE CARACTERES\n");
while(1){
c=getche();
y=c;
if(y<20){
break;
}
if((y>64 && y<92) || (y>96 && y<124)){
if(y<92) y=y+32;
y=y-97;
let1[y]++;
}
}
printf("\nDIGITE A SEGUNDA CADEIA DE CARACTERES\n");
while(1){
c=getche();
y=(int)c;
if(y<20){
break;
}
if((y>64 && y<92) || (y>96 && y<124)){
if(y<92) y=y+32;
y=y-97;
let2[y]++;
}
}
for(i=0;i<26;i++){
if(let1[i]!=let2[i]){
igual=0;
break;
}
}
if(igual) printf("\n AS SEQUENCIAS SÃO ANAGRAMAS \n\n");
else printf("\n AS SEQUENCIAS NÃO SÃO ANAGRAMAS\n\n");
system("pause");
}
RESPOSTA:
#include <stdio.h>
int qtd(void);
void main(){
register int x, y;
int qnum=5;
int numero[5]={10,2,4,5,30};
int temp;
y=qnum;
x=0;
if(numero[x]>numero[x+1]){
temp=numero[x];
numero[x]=numero[x+1];
numero[x+1]=temp;
printf("\n");
y=4;
while (y>-1){
printf(" %d",numero[y]);
y--;
printf("\n");
printf("\n \n");
system("pause");