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