Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 20
- #define D 30
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- void uredi (char niz[][D+1],int n)
- {
- int i,j,m;
- char p[D+1];
- for(i=0;i<n-1;i++){
- for(m=i,j=i+1;j<n;j++)
- if(strcmp (niz[j],niz[m])<0) m=j;
- if( m!=i)
- {
- strcpy (p, niz[i]);
- strcpy (niz[i],niz[m]);
- strcpy (niz[m],p);
- }
- }
- }
- int main(int argc, char *argv[]) {
- char niz[N][D+1];
- int n=0,i;
- printf("NIZ IMENA? \n");
- do
- gets(niz[n]);
- while (strlen(niz[n++]) > 0);
- n--;
- uredi (niz,n);
- printf ("\n UREDJENI NIZ IMENA: \n");
- for (i=0;i<n;puts (niz[i++]));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement