⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arreglo_ordenar.cpp

📁 Topics Practices: Programming and Numerical Methods Practice 1: Introduction to C Practice 2
💻 CPP
字号:
//Arreglos para ordenar
#include<conio.h>
#include<stdio.h>
void swap(int b[],int i ,int j)
{int aux;
   aux=b[i];
   b[i]=b[j];
   b[j]=aux;
}
void ordenar(int b[], int n)
{
     int pos,i,k;
     for(i=0 ; i<n; ++i)
     { pos=i;  
       for(k=i+1 ; k<n ; ++k)
       {
          if(b[pos]>b[k])
            pos=k;
       }
       swap(b,i,pos);
     }
} 
main()
{ int i,n;
  int b[n];
  printf("Cuantos dotos queres ingresar");
  scanf("%d",&n);
  printf("Ingresa %d numeros",n);
  for(i=0; i<n;++i)
 {
      scanf("%d",&b[i]);
 }
  ordenar(b,n);
  printf("Los elementos del arreglo ordenados son:\n");
  for(i=0; i<n; ++i)
  {
   printf("%d ,",b[i]);
  }
  
getch();
}                 
        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -