#include<stdio.h> #define max 50 void main() { int i, n, a[max]; printf("\nEnter no of Elements:"); scanf("%d",&n); generate(a,n); printf("\nRandom Elements:"); for(i=1;i<=n;i++) printf("%d ",a[i]); printf("\nSorted List Is:\n\n"); selsort(n,a); } void selsort(int n, int a[]) { int i,j,min,temp; for(i=1;i<=n-1;i++) { min = i; for(j=i+1;j<=n;j++) { if(a[j]<a[min]) min = j; } temp=a[i]; a[i]=a[min]; a[min]=temp; } for(i=1;i<=n;i++) printf("%d ",a[i]); } void generate(int a[],int n) { int i; for(i=0;i<n;i++) a[i]=rand()%100; }
2 Comments
compmiVfragri-Wichita Falls Sabian Pierce https://marketplace.visualstudio.com/items?itemName=9liaburtio-ge.Terra-Incognita-gratuita-2021
ReplyDeleteserdenomarb
exinquanshi Julie Davis https://www.tealpeople.ru/profile/Logicmaster-90-70-Software-27-FULL/profile
ReplyDeletenadecholi
Thanks,To visit this blog.