You are on page 1of 6

EJERCICIOS A RESOLVER

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159
int main(void)
{
int n,n1,j;
float gra;
double x,divid,divis,sig;
x=(gra*PI/180);
long int serie_potencia(long int n)
{
int i,suma=0;
for (i=1;i<=n;i++)
suma=suma+pow(i,i);
return suma;
}
long int ULAM(long int n1)
{
n1=n;
while (n1>1){
if (n1%2==0){
n1=(n1/2);
}
else{
n1=(n1*3+1);
}
printf("%ld ",n1);
}
}
double dividendo (double x)
{
int i;
for (j=1;j<2*i+1;j++)
divid=divid*x;
return divid;
}
double divisor (double x)
{
int i;
for (j=1;j>=2*i+1;j++)
divis=divis*j;

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

return divis;
}
int signo (int n)
{
int i;
if (i%2==0){
sig=1;
}else{
sig=-1;
}
return sig;
}
printf("Introduce un nuemro N\?");
scanf("%d",&n);
printf("\nLa serie de potencias es: %ld\n",serie_potencia(n));
printf("\n\nLa serie de ULAM es:%ld, %ld",ULAM(n));
return (EXIT_SUCCESS);
}

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool EsMayuscula (char c)
{
if (c>90){
return true;
}
else {
return false;
}
}
char AMinuscula (char c)
{
if (c<97){
c=c+32;
}
else {
c=c;
}
}
bool EsVocal (char c)
{

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

1
2
3
4
5
6
7
8
9
10
11

if (c==97 || c==101 || c==105 || c==111 || c==117){


return true;
}
else{
return false;
}
}
int main(void)
{
char d,e;
printf("INTRODUZCA UN CARACTER:");
scanf("%c",&d);
e=d;
EsMayuscula(d);
e=AMinuscula(e);
if (EsVocal(e))
printf("\n%c es vocal\n",d);
else
printf("\n%c es consonante\n",d);
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
int dias,mes;
char dia;

12
13
14
printf("Introduzca los dias que tiene el mes:\?");
15
scanf("%d",&dias);
16
17
18
printf("\nIntroduzca el dia de la semana del primer dia del mes (L,M,X,J,V,S,D)\?");
19
fflush(stdin);
20
scanf("%c",&dia);
21
22 printf("%d %c",dias,dia);
23
24
if (dia=='L')
25
26
mes==6;
27
if (dia=='M' && dias==30)
28
mes=9;
29
else mes=12;
30
if (dia=='X' && dias==30)
31
mes=4;
32
else mes=7;
33
if (dia=='J' && dias==31)
34
mes=1;
35
if (dia='V')
36
mes=5;
37
if (dia='S')
38
mes=8;
39
if (dia='D' && dias==30)
40
mes=11;
41
else if (dia='D' && dias==31)
42
mes=3;
43
else mes=2;
44
45 switch (mes){
46 case 1:
47
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE ENERO DEL
2015");break;
48 case 2:
49
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE FEBRERO DEL
2015");break;
50 case 3:
51
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE MARZO DEL
2015");break;
52 case 4:
53
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE ABRIL DEL
2015");break;
54 case 5:
55
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE MAYO DEL
2015");break;
56 case 6:
57
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE JUNIO DEL
2015");break;
58 case 7:
59
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE JULIO DEL
2015");break;
60 case 8:
61
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE AGOSTO DEL
2015");break;
62 case 9:
63
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE SEPTIEMBRE DEL
2015");break;
64 case 10:
65
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE OCTUBRE DEL
2015");break;
66 case 11:
67
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE NOVIEMBRE DEL
2015");break;
68 case 12:
69
printf("\nA CONTINUACION SE MUESTRA EL CALENDARIO DEL MES DE DICIEMBRE DEL

2015");break;
70 }
71
72
printf("\n------------------------------------------------------------------");
73
printf("\n LUNES
MARTES
MIERCOLES
JUEVES
VIERNES
SABADO
DOMINGO");
74
printf("\n------------------------------------------------------------------");
75 }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
bool es_primo (int n)
{
int divisor;
for (divisor=2;divisor<n;divisor++)
if (n%divisor==0)
return false;
return true;
}
int main(void)
{
int numero1,numero2,i;
char u;
u=163;
printf("Introduzca el primer n%cmero del intervalo [x,y] x=",u);
scanf("%d",&numero1);
printf("\nIntroduzca el segundo n%cmero del intervalo [x,y] y=",u);
scanf("%d",&numero2);

for (i=numero1;i<=numero2;i++)
if (i+2<numero2)
if (es_primo(i))
if (es_primo(i+2))
printf("\n%d y %d son primos gemelos",i,i+2);
i++;
printf("\n");
return 0;
}

No he entendido el concepto de recursividad

You might also like