Ejemplo n.º 1
0
int main(){
    
    int number[MAXSIZE]={75,30,21,50,45,9,16,12,31,40};
    
    int i;
      
        
            printf("Sequence before Selection sort :\n");
                for(i=0;i<10;i++){
                    if(i==9){printf("%d\n",number[i]);}
                    else{
                    printf("%d ->",number[i]);
                    }
                }
            
            Selection_sort(number);                               
                            
            
            printf("Sequence after Selection sort :\n");
                for(i=0;i<10;i++){
                    if(i==9){printf("%d\n",number[i]);}
                    else{
                    printf("%d ->",number[i]);
                    }
                }              
            
        
    
    system("pause");
    return(0);
    }
int main()
{
    srand((unsigned)time(NULL));
    int i,a[20];
    int size=sizeof (a)/sizeof (a[0]);
    for(i=0;i<size;i++)
    {
        a[i]=rand()%100+1;
    }

    printf("The original array:\n");
    for (i=0;i<size;i++)
    {
        printf("%d\n",a[i]);
    }
    Selection_sort(a,size);

    printf("The sorted array:\n");
    for (i=0;i<size;i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}