SlideShare una empresa de Scribd logo
Programación en C 34
Ordenación por selección
• En éste método, en el i-ésimo paso seleccionamos el
elemento con la llave de menor valor, entre a[i],…,
a[n] y lo intercambiamos con a[i].
• Como resultado, después de i pasadas, el i-ésimo
elemento menor ocupará a[1],…, a[i] en el lugar
ordenado.
• La complejidad del algoritmo es O(n2).
Programación en C 35
Ordenación por selección
7
6
5
4
3
2
1
Or
12
12
42
42
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 36
Ordenación por selección
7
6
5
4
3
2
1
Or
55
12
12
42
42
42
67
44
18
94
12
06
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 37
Ordenación por selección
7
6
5
4
3
2
1
Or
18
55
12
12
42
42
42
42
67
44
55
94
12
06
67
44
18
94
12
06
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 38
Ordenación por selección
7
6
5
4
3
2
1
Or
18
18
55
12
12
42
42
42
42
42
67
44
55
94
12
06
67
44
55
94
12
06
67
44
18
94
12
06
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 39
Ordenación por selección
7
6
5
4
3
2
1
Or
18
18
18
55
12
12
42
42
42
42
42
42
67
94
55
44
12
06
67
44
55
94
12
06
67
44
55
94
12
06
67
44
18
94
12
06
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 40
Ordenación por selección
7
6
5
4
3
2
1
Or
18
18
18
18
55
12
12
42
42
42
42
42
42
42
67
94
55
44
12
06
67
94
55
44
12
06
67
44
55
94
12
06
67
44
55
94
12
06
67
44
18
94
12
06
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 41
Ordenación por selección
7
6
5
4
3
2
1
Or
18
18
18
18
18
55
12
12
42
42
42
42
42
42
42
42
67
94
55
44
12
06
67
94
55
44
12
06
94
67
55
44
12
06
67
44
55
94
12
06
67
44
55
94
12
06
67
44
18
94
12
06
67
44
18
94
55
06
67
06
18
94
55
44
Programación en C 42
/************************************************************************
* Programa: ord_seleccion.c *
* Descripción: Programa que ordena un array mediante el metodo seleccion *
* Autor: Pedro Corcuera *
* Revisión: 1.0 2/02/2008 *
************************************************************************/
#include <stdio.h>
main()
{
float t,a[]={10.0,8.0,5.5,3.4,3.2,2.5,2.2,1.5};
int i,j,k,n;
n = sizeof(a)/sizeof (float);
for(i = 0; i < n-1; i++)
{
k = i; t = a[i];
for (j = i+1; j < n; j++)
{
if (a[j] < t)
{ t = a[j]; k = j;
}
a[k] = a[i]; a[i] = t;
}
}
for(i = 0; i < n; i++)
printf("%d %10.2f n",i,a[i]);
}
Ordenación por selección: código

Más contenido relacionado

Último

DIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptx
DIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptxDIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptx
DIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptx
KeylaArlethTorresOrt
 
EXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdf
EXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdfEXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdf
EXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdf
hugodennis88
 
Calculo-de-Camaras-Frigorificas.pdf para trabajos
Calculo-de-Camaras-Frigorificas.pdf para trabajosCalculo-de-Camaras-Frigorificas.pdf para trabajos
Calculo-de-Camaras-Frigorificas.pdf para trabajos
JuanCarlos695207
 
1. Introduccion a las excavaciones subterraneas (1).pdf
1. Introduccion a las excavaciones subterraneas (1).pdf1. Introduccion a las excavaciones subterraneas (1).pdf
1. Introduccion a las excavaciones subterraneas (1).pdf
raulnilton2018
 
DIAGRAMA ELECTRICOS y circuito electrónicos
DIAGRAMA ELECTRICOS y circuito electrónicosDIAGRAMA ELECTRICOS y circuito electrónicos
DIAGRAMA ELECTRICOS y circuito electrónicos
LuisAngelGuarnizoBet
 
METRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdf
METRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdfMETRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdf
METRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdf
Augusto César Dávila Callupe
 
Presentación- de motor a combustión -diesel.pptx
Presentación- de motor a combustión -diesel.pptxPresentación- de motor a combustión -diesel.pptx
Presentación- de motor a combustión -diesel.pptx
ronnyrocha223
 
tipos de energias: la Energía Radiante.pdf
tipos de energias: la Energía Radiante.pdftipos de energias: la Energía Radiante.pdf
tipos de energias: la Energía Radiante.pdf
munozvanessa878
 
OPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTO
OPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTOOPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTO
OPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTO
GERARDO GONZALEZ
 
exposicion sobre los tipos de cortes de rolas para la produccion de chapas
exposicion sobre los tipos de cortes de rolas para la produccion de chapasexposicion sobre los tipos de cortes de rolas para la produccion de chapas
exposicion sobre los tipos de cortes de rolas para la produccion de chapas
raul958375
 
muros de contencion, diseño y generalidades
muros de contencion, diseño y generalidadesmuros de contencion, diseño y generalidades
muros de contencion, diseño y generalidades
AlejandroArturoGutie1
 
Aletas de transferencia de calor o superficies extendidas dylan.pdf
Aletas de transferencia de calor o superficies extendidas dylan.pdfAletas de transferencia de calor o superficies extendidas dylan.pdf
Aletas de transferencia de calor o superficies extendidas dylan.pdf
elsanti003
 
diagrama de flujo. en el área de ingeniería
diagrama de flujo. en el área de ingenieríadiagrama de flujo. en el área de ingeniería
diagrama de flujo. en el área de ingeniería
karenperalta62
 
Sesión 03 universidad cesar vallejo 2024
Sesión 03 universidad cesar vallejo 2024Sesión 03 universidad cesar vallejo 2024
Sesión 03 universidad cesar vallejo 2024
FantasticVideo1
 
PRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICA
PRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICAPRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICA
PRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICA
carmenquintana18
 
INVENTARIO CEROO Y DINAMICAA FABRIL.pptx
INVENTARIO CEROO Y DINAMICAA FABRIL.pptxINVENTARIO CEROO Y DINAMICAA FABRIL.pptx
INVENTARIO CEROO Y DINAMICAA FABRIL.pptx
FernandoRodrigoEscal
 
Infografía operaciones básicas construcción .pdf
Infografía operaciones básicas construcción .pdfInfografía operaciones básicas construcción .pdf
Infografía operaciones básicas construcción .pdf
Carlos Pulido
 
Equipo 4. Mezclado de Polímeros quimica de polimeros.pptx
Equipo 4. Mezclado de Polímeros quimica de polimeros.pptxEquipo 4. Mezclado de Polímeros quimica de polimeros.pptx
Equipo 4. Mezclado de Polímeros quimica de polimeros.pptx
angiepalacios6170
 
Uso de equipos de protección personal.pptx
Uso de equipos de protección personal.pptxUso de equipos de protección personal.pptx
Uso de equipos de protección personal.pptx
OmarPadillaGarcia
 
Infografía de operaciones básicas....pdf
Infografía de operaciones básicas....pdfInfografía de operaciones básicas....pdf
Infografía de operaciones básicas....pdf
jahirrtorresa
 

Último (20)

DIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptx
DIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptxDIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptx
DIAPOSITIVA DE LA NORMA ISO 22000 EXPOSICI�N.pptx
 
EXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdf
EXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdfEXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdf
EXPOSICIÓN NTP IEC 60364-1 - Orlando Chávez Chacaltana.pdf
 
Calculo-de-Camaras-Frigorificas.pdf para trabajos
Calculo-de-Camaras-Frigorificas.pdf para trabajosCalculo-de-Camaras-Frigorificas.pdf para trabajos
Calculo-de-Camaras-Frigorificas.pdf para trabajos
 
1. Introduccion a las excavaciones subterraneas (1).pdf
1. Introduccion a las excavaciones subterraneas (1).pdf1. Introduccion a las excavaciones subterraneas (1).pdf
1. Introduccion a las excavaciones subterraneas (1).pdf
 
DIAGRAMA ELECTRICOS y circuito electrónicos
DIAGRAMA ELECTRICOS y circuito electrónicosDIAGRAMA ELECTRICOS y circuito electrónicos
DIAGRAMA ELECTRICOS y circuito electrónicos
 
METRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdf
METRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdfMETRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdf
METRADOS_Y_PRESUPUESTO_EN_SISTEMA_DRYWALL_24-05.pdf
 
Presentación- de motor a combustión -diesel.pptx
Presentación- de motor a combustión -diesel.pptxPresentación- de motor a combustión -diesel.pptx
Presentación- de motor a combustión -diesel.pptx
 
tipos de energias: la Energía Radiante.pdf
tipos de energias: la Energía Radiante.pdftipos de energias: la Energía Radiante.pdf
tipos de energias: la Energía Radiante.pdf
 
OPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTO
OPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTOOPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTO
OPERACIONES BÁSICAS (INFOGRAFIA) DOCUMENTO
 
exposicion sobre los tipos de cortes de rolas para la produccion de chapas
exposicion sobre los tipos de cortes de rolas para la produccion de chapasexposicion sobre los tipos de cortes de rolas para la produccion de chapas
exposicion sobre los tipos de cortes de rolas para la produccion de chapas
 
muros de contencion, diseño y generalidades
muros de contencion, diseño y generalidadesmuros de contencion, diseño y generalidades
muros de contencion, diseño y generalidades
 
Aletas de transferencia de calor o superficies extendidas dylan.pdf
Aletas de transferencia de calor o superficies extendidas dylan.pdfAletas de transferencia de calor o superficies extendidas dylan.pdf
Aletas de transferencia de calor o superficies extendidas dylan.pdf
 
diagrama de flujo. en el área de ingeniería
diagrama de flujo. en el área de ingenieríadiagrama de flujo. en el área de ingeniería
diagrama de flujo. en el área de ingeniería
 
Sesión 03 universidad cesar vallejo 2024
Sesión 03 universidad cesar vallejo 2024Sesión 03 universidad cesar vallejo 2024
Sesión 03 universidad cesar vallejo 2024
 
PRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICA
PRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICAPRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICA
PRIMERA Y SEGUNDA LEY DE LA TERMODINÁMICA
 
INVENTARIO CEROO Y DINAMICAA FABRIL.pptx
INVENTARIO CEROO Y DINAMICAA FABRIL.pptxINVENTARIO CEROO Y DINAMICAA FABRIL.pptx
INVENTARIO CEROO Y DINAMICAA FABRIL.pptx
 
Infografía operaciones básicas construcción .pdf
Infografía operaciones básicas construcción .pdfInfografía operaciones básicas construcción .pdf
Infografía operaciones básicas construcción .pdf
 
Equipo 4. Mezclado de Polímeros quimica de polimeros.pptx
Equipo 4. Mezclado de Polímeros quimica de polimeros.pptxEquipo 4. Mezclado de Polímeros quimica de polimeros.pptx
Equipo 4. Mezclado de Polímeros quimica de polimeros.pptx
 
Uso de equipos de protección personal.pptx
Uso de equipos de protección personal.pptxUso de equipos de protección personal.pptx
Uso de equipos de protección personal.pptx
 
Infografía de operaciones básicas....pdf
Infografía de operaciones básicas....pdfInfografía de operaciones básicas....pdf
Infografía de operaciones básicas....pdf
 

Destacado

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 

Destacado (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

algortimo de seleccion.pdf

  • 1. Programación en C 34 Ordenación por selección • En éste método, en el i-ésimo paso seleccionamos el elemento con la llave de menor valor, entre a[i],…, a[n] y lo intercambiamos con a[i]. • Como resultado, después de i pasadas, el i-ésimo elemento menor ocupará a[1],…, a[i] en el lugar ordenado. • La complejidad del algoritmo es O(n2).
  • 2. Programación en C 35 Ordenación por selección 7 6 5 4 3 2 1 Or 12 12 42 42 67 44 18 94 55 06 67 06 18 94 55 44
  • 3. Programación en C 36 Ordenación por selección 7 6 5 4 3 2 1 Or 55 12 12 42 42 42 67 44 18 94 12 06 67 44 18 94 55 06 67 06 18 94 55 44
  • 4. Programación en C 37 Ordenación por selección 7 6 5 4 3 2 1 Or 18 55 12 12 42 42 42 42 67 44 55 94 12 06 67 44 18 94 12 06 67 44 18 94 55 06 67 06 18 94 55 44
  • 5. Programación en C 38 Ordenación por selección 7 6 5 4 3 2 1 Or 18 18 55 12 12 42 42 42 42 42 67 44 55 94 12 06 67 44 55 94 12 06 67 44 18 94 12 06 67 44 18 94 55 06 67 06 18 94 55 44
  • 6. Programación en C 39 Ordenación por selección 7 6 5 4 3 2 1 Or 18 18 18 55 12 12 42 42 42 42 42 42 67 94 55 44 12 06 67 44 55 94 12 06 67 44 55 94 12 06 67 44 18 94 12 06 67 44 18 94 55 06 67 06 18 94 55 44
  • 7. Programación en C 40 Ordenación por selección 7 6 5 4 3 2 1 Or 18 18 18 18 55 12 12 42 42 42 42 42 42 42 67 94 55 44 12 06 67 94 55 44 12 06 67 44 55 94 12 06 67 44 55 94 12 06 67 44 18 94 12 06 67 44 18 94 55 06 67 06 18 94 55 44
  • 8. Programación en C 41 Ordenación por selección 7 6 5 4 3 2 1 Or 18 18 18 18 18 55 12 12 42 42 42 42 42 42 42 42 67 94 55 44 12 06 67 94 55 44 12 06 94 67 55 44 12 06 67 44 55 94 12 06 67 44 55 94 12 06 67 44 18 94 12 06 67 44 18 94 55 06 67 06 18 94 55 44
  • 9. Programación en C 42 /************************************************************************ * Programa: ord_seleccion.c * * Descripción: Programa que ordena un array mediante el metodo seleccion * * Autor: Pedro Corcuera * * Revisión: 1.0 2/02/2008 * ************************************************************************/ #include <stdio.h> main() { float t,a[]={10.0,8.0,5.5,3.4,3.2,2.5,2.2,1.5}; int i,j,k,n; n = sizeof(a)/sizeof (float); for(i = 0; i < n-1; i++) { k = i; t = a[i]; for (j = i+1; j < n; j++) { if (a[j] < t) { t = a[j]; k = j; } a[k] = a[i]; a[i] = t; } } for(i = 0; i < n; i++) printf("%d %10.2f n",i,a[i]); } Ordenación por selección: código