Sunteți pe pagina 1din 111

Estrategias para resolver problemas

Inicio Sum1 = 1 Sum2 = 1 Con = 0

int main (){ int sum1 = 1; int sum2 = 1; int con = 0; int res;
Res = Sum1+Sum2

Con < 1000

true
Imprimir Res

false
Sum2 = Sum1 Sum1 = Res

while (con<1000){ res = sum1 + sum2; printf ("%d, ", res); sum2 = sum1; sum1 = res; con++; } system("Pause"); return 0; } // Fin main

Fin
Con ++

33

M. en C. Miriam Balbuena

26/04/2012

Ejercicio
Disear el algoritmo y crear el programa para obtener la siguiente serie:
2, 3, 4, 6, 6, 9, 8, 12, 10, 15, 12, 18, 14, 21, 16

Mostrar los primeros 100 nmeros de la serie. Tiempo para la realizacin: 15 minutos.

34

M. en C. Miriam Balbuena

26/04/2012

Arreglos

35

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Variable que hace referencia a varias posiciones de memoria. Cada posicin se identifica con un ndice. El ndice comienza en 0.

miArreglo

36

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Variable que hace referencia a varias posiciones de memoria. Cada posicin se identifica con un ndice. El ndice comienza en 0.

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

37

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Declaracin:
int main (){

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

Tipo de dato int miArreglo[8];


system("Pause"); return 0; } // Fin main

38

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Declaracin:
int main (){ int miArreglo[8]; system("Pause"); return 0; } // Fin main

miArreglo[0] Corchetes para indicar que es arreglo. miArreglo miArreglo[1] miArreglo[2] miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

39

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Declaracin:
int main (){

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

Nombre del arreglo


int miArreglo[8]; system("Pause"); return 0; } // Fin main

40

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Asignacin de memoria:
Asignacin de 8 posiciones de memoria para valores de tipo entero. miArreglo
system("Pause"); return 0; } // Fin main

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

int main (){

int miArreglo[8];

41

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Asignacin de memoria:
int main (){ int miArreglo[8]; miArreglo[0] = 5

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

system("Pause"); return 0; } // Fin main

42

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Asignacin de memoria:
int main (){ int miArreglo[8]; miArreglo[0] = 5;

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

5 10

miArreglo[1] = 10; system("Pause"); return 0; } // Fin main

43

M. en C. Miriam Balbuena

26/04/2012

Qu es un arreglo?
Asignacin de memoria:
int main (){ int miArreglo[8]; miArreglo[0] = 5;

miArreglo[0] miArreglo[1] miArreglo[2] miArreglo miArreglo[3] miArreglo[4] miArreglo[5] miArreglo[6] miArreglo[7]

5 10 15

miArreglo[1] = 10; miArreglo[2] = miArreglo[0]+ miArreglo[1] system("Pause"); return 0; } // Fin main

44

M. en C. Miriam Balbuena

26/04/2012

Ejercicio
Crear un programa que declare un arreglo llamado "vector" de 10 posiciones. Asignar el valor de 10 a cada posicin del arreglo. Mostrar todas las posiciones del arreglo.

vector[0] vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9]

10 10 10 10 10 10 10 10 10 10

45

M. en C. Miriam Balbuena

26/04/2012

Cdigo repetitivo.
int main (){ int vector [10]; vector[0] vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] printf printf printf printf = = = = = = = = = = 10; 10; 10; 10; 10; 10; 10; 10; 10; 10; vector[0]); vector[1]); vector[2]); vector[3]);

("%d", ("%d", ("%d", ("%d",

system("Pause"); return 0; } // Fin main


46 M. en C. Miriam Balbuena 26/04/2012

Cdigo repetitivo.
int vector [10];

int vector [10];


vector[0] vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] printf printf printf printf = = = = = = = = = = 10; 10; 10; 10; 10; 10; 10; 10; 10; 10; vector[0]); vector[1]); vector[2]); vector[3]);

int i = 0; while (i<10){ vector[i] = 10; i++; }

("%d", ("%d", ("%d", ("%d",

i = 0; while (i<10){ printf ("%d", vector[i]); i++; } }

47

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
48 M. en C. Miriam Balbuena 26/04/2012

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9]

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
49

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i 0

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; }

vector[1] vector[2] true vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i 0

i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
50

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
51

10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i 0

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
52

10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i 1

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
53

10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i 1

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; }

10

vector[1] vector[2] true vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i 1

i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
54

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
55

10 10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
56

10 10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
57

10 10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; }

10 10

vector[1] vector[2] true vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
58

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
59

10 10 10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
60

10 10 10

vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

M. en C. Miriam Balbuena

26/04/2012

Cmo funciona?
int main (){

vector[0]
int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; }

10 10 10 10 10 10 10 10 10 10 10

vector[1] vector[2] false vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9] i

i = 0; while (i<10){ printf ("%d", vector[i]); i++; } system("Pause"); return 0; } // Fin main
61

M. en C. Miriam Balbuena

26/04/2012

Ejercicio
Crear un arreglo de 100 posiciones. Llenar el arreglo con la tabla del 2. Mostrar el arreglo en pantalla. Tiempo: 5 min.
62

vector[0] vector[1] vector[2] vector[3] vector[4] vector[5] vector[6] vector[7] vector[8] vector[9]

0 2 4 6 8 10 12 14 16 18

M. en C. Miriam Balbuena

26/04/2012

Ciclo for

63

M. en C. Miriam Balbuena

26/04/2012

For
Funciona similar al while. Es muy til para recorrer arreglos. Sintaxis:
for (inicializacin ; condicin ; incremento){ // Bloque de cdigo que se repite. }

64

M. en C. Miriam Balbuena

26/04/2012

Ciclo while
int main (){ int vector [10]; int i = 0; while (i<10){ vector[i] = 10; i++; } }

i=0

true
i<10 Vector[i] = 10 i++

false Fin
65 M. en C. Miriam Balbuena 26/04/2012

Ciclo for
int main (){ int vector [10]; int i = 0; for (i=0; i<10, i++){ vector[i] = 10; }

i=0

true
i<10 Vector[i] = 10 i++

false Fin
66 M. en C. Miriam Balbuena 26/04/2012

Ciclo for
int main (){ int vector [10]; int i = 0; for ( i=0; i<10, i++){ vector[i] = 10; }

i=0

true
i<10 Vector[i] = 10 i++

false Fin
67 M. en C. Miriam Balbuena 26/04/2012

Ciclo for
int main (){ int vector [10]; int i = 0; for ( i=0; i<10, vector[i] = 10; }

i++){

i=0

true
i<10 Vector[i] = 10 i++

false Fin
68 M. en C. Miriam Balbuena 26/04/2012

Ciclo for
int main (){ int vector [10]; int i = 0; for ( i=0; i<10, i++){ vector[i] = 10; }

i=0

true
i<10 Vector[i] = 10 i++

false Fin
69 M. en C. Miriam Balbuena 26/04/2012

Ciclo for
int main (){ int vector [10]; int i = 0; for (i=0; i<10, i++){ vector[i] = 10; }

i=0

true
i<10 Vector[i] = 10 i++

false Fin
70 M. en C. Miriam Balbuena 26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){ int longitudSerie = 50; int i; for (i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); } }
i=0

true
i<long/2 Imprime 2*i Imprime 3*i i++

false Fin

71

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){ int longitudSerie = 50; int i; for (i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); } i=0 }

longitudSerie

50

true
i<long /2 Imprime 2*i Imprime 3*i i++

false Fin

72

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 1

true
i<long /2 Imprime 2*i Imprime 3*i i++

false Fin

73

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 1

true

true
i<long /2 Imprime 2*i Imprime 3*i i++

false Fin

74

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 1

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3,

false Fin

75

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 2

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3,

false Fin

76

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 2

true

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3,

false Fin

77

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 2

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3, 4, 6,

false Fin

78

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 3

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3, 4, 6,

false Fin

79

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 3

true

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3, 4, 6,

false Fin

80

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 3

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3, 4, 6, 6, 9

false Fin

81

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 4

true
i<long /2 Imprime 2*i Imprime 3*i i++

2, 3, 4, 6, 6, 9,

false Fin

82

M. en C. Miriam Balbuena

26/04/2012

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 26

false 2, 3, 4, 6, 6, 9, 8, 12, 10, 15, 12, 18, 14, 21, 16, 24, 18, 27, 20, 30, 22, 33, 24, 36, 26, 39, 28, 42, 30, 45, 32, 48, 34, 51, 36, 54, 38, 57, 40, 60, 42, 63, 44, 66, 46, 69, 48, 72, 50, 75, BUILD SUCCESSFUL (total time: 1 second)
M. en C. Miriam Balbuena 26/04/2012

true
i<long /2 Imprime 2*i Imprime 3*i i++

false Fin

83

Ejemplo: Mostrar la serie: 2, 3, 4, 6, 6, 9, 8, 12, 10,


int main (){

longitudSerie
int longitudSerie = 50; int i; for ( i = 1; i<=(longitudSerie/2); i++){ printf("%d, ", 2*i); printf("%d, ", 3*i); }
i=0

50 25

true
i<long /2 Imprime 2*i Imprime 3*i i++

false Fin

2, 3, 4, 6, 6, 9, 8, 12, 10, 15, 12, 18, 14, 21, 16, 24, 18, 27, 20, 30, 22, 33, 24, 36, 26, 39, 28, 42, 30, 45, 32, 48, 34, 51, 36, 54, 38, 57, 40, 60, 42, 63, 44, 66, 46, 69, 48, 72, 50, 75, Presione una tecla para continuar
M. en C. Miriam Balbuena 26/04/2012

84

Ejercicio
Declarar un arreglo llamado "a" de 100 posiciones. Utilizar un ciclo for para llenar el arreglo con valores del 100 al 1. Mostrar el arreglo en pantalla. Tiempo: 5 min.
85

a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]

100 99 98 97 96 95 94 93 92 91

M. en C. Miriam Balbuena

26/04/2012

int main (){ int vector [10]; int i; for (i = 0; i<10; i++){ vector[i] = 10; } }

86

M. en C. Miriam Balbuena

26/04/2012

Recibir datos del teclado

87

M. en C. Miriam Balbuena

26/04/2012

Cmo recibir entradas del teclado?


scanf(); Sintaxis:
scanf ("%d", &miVariable);

Importar la librera #include <stdio.h>

#include <stdio.h> int main(){ int miVariable; scanf ("%d", &miVariable); return 0; }
88 M. en C. Miriam Balbuena 26/04/2012

Ejemplo
int main () { numero int numero; printf ("Dame un nmero\n"); scanf ("%d", &numero); printf ("El nmero es: %d",numero); return 0; }

89

M. en C. Miriam Balbuena

26/04/2012

Ejemplo
int main () { numero int numero; printf ("Dame un nmero\n"); scanf ("%d", &numero); printf ("El nmero es: %d",numero); return 0; }

Dame un nmero \n

90

M. en C. Miriam Balbuena

26/04/2012

Ejemplo
int main () { numero int numero; printf ("Dame un nmero\n"); scanf ("%d", &numero); printf ("El nmero es: %d",numero); return 0; } 10

numero
91

Dame un nmero\n 10
26/04/2012

M. en C. Miriam Balbuena

Ejemplo
int main () { numero int numero; printf ("Dame un nmero\n"); scanf ("%d", &numero); printf ("El nmero es: %d",numero); return 0; } 10

Dame un nmero\n 10\n El nmero es 10


92 M. en C. Miriam Balbuena 26/04/2012

Ejercicio
Solicitar dos nmeros del usuario. Guardar los nmeros en dos variables llamadas "a" y "b" Decidir cual de los dos nmeros es mayor e informrselo al usuario. Ejemplo:
Dame un nmero 9 Dame otro nmero 8 El nmero mayor es 9 Presione cualquier tecla para continuar
M. en C. Miriam Balbuena 26/04/2012

93

Algunos programas con arreglos


Ejemplo: Buscar el nmero ms grande de un arreglo.

94

M. en C. Miriam Balbuena

26/04/2012

int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); } // Fin main
95 M. en C. Miriam Balbuena 26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
96 M. en C. Miriam Balbuena 26/04/2012

tamano i max

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
97 M. en C. Miriam Balbuena 26/04/2012

tamano i max

De que tamao quieres el arreglo?

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
98 M. en C. Miriam Balbuena 26/04/2012

tamano i max

De que tamao quieres el arreglo? 5

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
99 M. en C. Miriam Balbuena 26/04/2012

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

De que tamao quieres el arreglo? 5

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
100 M. en C. Miriam Balbuena 26/04/2012

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 0

De que tamao quieres el arreglo? 5

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
101

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 0

De que tamao quieres el arreglo? 5 Ingresa numeros[0]:


M. en C. Miriam Balbuena 26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
102

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 0 4

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4


M. en C. Miriam Balbuena 26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
103

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 0 4

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4


M. en C. Miriam Balbuena 26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
104

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 1 4

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4


M. en C. Miriam Balbuena 26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
105

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 1 4

M. en C. Miriam Balbuena

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4 Ingresa numeros[1]:


26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
106

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 1 4 8

M. en C. Miriam Balbuena

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8


26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
107

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 1 4 8

M. en C. Miriam Balbuena

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8


26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
108

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 2 4 8

M. en C. Miriam Balbuena

De que tamao quieres el arreglo? 5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8


26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
109

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 2 4 8

M. en C. Miriam Balbuena

5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]:

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
110

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 2 4 8 9

M. en C. Miriam Balbuena

5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
111

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 2 4 8 9

M. en C. Miriam Balbuena

5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
112

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 3 4 8 9

M. en C. Miriam Balbuena

5 Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
113

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 3 4 8 9

M. en C. Miriam Balbuena

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9 Ingresa numeros[3]:

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
114

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 3 4 8 9 3

M. en C. Miriam Balbuena

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9 Ingresa numeros[3]: 3

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
115

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 3 4 8 9 3

M. en C. Miriam Balbuena

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9 Ingresa numeros[3]: 3

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
116

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 4 4 8 9 3

M. en C. Miriam Balbuena

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9 Ingresa numeros[3]: 3

26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 4 8 9 3 5 4

}
117

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]:

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 4 8 9 3 1 5 4

}
118

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 4 8 9 3 1 5 4

}
119

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 4 8 9 3 1 5 5

}
120

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 5 4 4 8 9 3 1

}
121

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 0 4 4 8 9 3 1

}
122

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 0 4 4 8 9 3 1

}
123

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 0 4 4 8 9 3 1

}
124

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 1 4 4 8 9 3 1

}
125

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 1 4 4 8 9 3 1

}
126

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 1 8 4 8 9 3 1

}
127

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 1 8 4 8 9 3 1

}
128

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 2 8 4 8 9 3 1

}
129

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 2 8 4 8 9 3 1

}
130

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 2 9 4 8 9 3 1

}
131

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 2 9 4 8 9 3 1

}
132

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 3 9 4 8 9 3 1

}
133

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 3 9 4 8 9 3 1

}
134

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 3 9 4 8 9 3 1

}
135

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 4 9 4 8 9 3 1

}
136

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 4 9 4 8 9 3 1

}
137

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 4 9 4 8 9 3 1

}
138

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 5 9 4 8 9 3 1

}
139

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 5 9 4 8 9 3 1

}
140

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 printf ("El mayor es: %d",max); Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 M. en C. Miriam Balbuena 26/04/2012 Ingresa numeros[4]: 1

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } printf ("El mayor es: %d",max); }
141

tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4]

5 5 9 4 8 9 3 1

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 Ingresa numeros[4]: 1 El mayor es: 9
M. en C. Miriam Balbuena 26/04/2012

Buscar el nmero ms grande de un arreglo


int main (){ int tamano, i, max; printf ("De qu tamao quieres el arreglo? \n"); scanf ("%d", &tamano); int numeros [tamano]; for (i=0; i<tamano ; i++){ printf("\n Ingresa numeros[%d]: ", i); scanf ("%d", &numeros[i]); } max = numeros[0]; for (i=0; i<tamano ; i++){ if (max < numeros[i]) max = numeros[i]; } tamano i max numeros [0] numeros [1] numeros [2] numeros [3] numeros [4] 5 5 9 4 8 9 3 1

}
142

Ingresa numeros[0]: 4 Ingresa numeros[1]: 8 Ingresa numeros[2]: 9 Ingresa numeros[3]: 3 printf ("El mayor es: %d",max); Ingresa numeros[4]: 1 El mayor es: 9 M. en PresioneBalbuena 26/04/2012 C. Miriam cualquier tecla para continuar

Ejercicios
1) Crear un programa que obtenga los valores de un arreglo de teclado. El programa debe determinar el ms pequeo de los elementos del arreglo y mostrarlo en pantalla. 2) Crear un programa que cree un arreglo de 5 posiciones. El programa debe pedir los 5 valores al usuario para llenar el arreglo. Posteriormente debe calcular el promedio de los 5 valores y mostrarlo en pantalla. 3) Crear un programa que reciba N valores y los almacene en un arreglo. El programa debe mostrar los valores del arreglo ordenados de menor a mayor.
143 M. en C. Miriam Balbuena 26/04/2012

S-ar putea să vă placă și