Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char ** citsiruri(int *pn);
- void bubblesort(char **ts,int n);
- void schimba(char**p,char**q);
- void elib(char **ts,int n);
- void afis(char **ts,int n);
- int main()
- { char **ts;
- int n;
- ts=citsiruri(&n);
- bubblesort(ts,n);
- printf(":sirurile in ord cresc:\n");
- afis(ts,n);
- elib(ts,n);
- return 0;
- }
- char ** citsiruri(int *pn)
- {
- printf("nr siruri:");
- scanf("%d",pn);
- char **ts=(char**)calloc(*pn,sizeof(char));
- if(ts==NULL)
- {
- exit(1);
- }
- char s[51];
- int i;
- printf("sirurile de caractere:");
- for(i=0; i<*pn; i++)
- {
- scanf("%50s",s);
- ts[i]=(char*)malloc(strlen(s)+1);
- if(ts[i]==NULL) exit(1);
- strcpy(ts[i],s);
- }
- return ts;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement