Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N 16
- int main (void)
- {
- char **stroka, *t, symb, c;
- int i, schet, schet1, j, fl, k;
- schet1=0;
- stroka=malloc(N*sizeof(char*));
- do
- {
- schet1++;
- stroka=realloc(stroka, schet1*sizeof(char*));
- i=0;
- schet=1;
- stroka[schet1-1]=malloc(schet*sizeof(char));
- *(stroka[schet1-1]+i)=getchar();
- while ((*(stroka[schet1-1]+i)!=EOF) && (*(stroka[schet1-1]+i)!='\n'))
- {
- i++;
- schet++;
- stroka[r-1]=realloc(stroka[schet1-1], schet*sizeof(char));
- *(stroka[schet1-1]+i)=getchar();
- }
- symb=*(stroka[schet1-1]+i);
- *(stroka[schet1-1]+i)='\0';
- }
- while (symb!=EOF);
- for (;k<r;k++)
- {
- fl=0;
- for (j=0; j<schet1-1; j++)
- {
- if (strcmp(stroka[j], stroka[j+1])>0)
- {
- t=stroka[j];
- stroka[j]=stroka[j+1];
- stroka[j+1]=t;
- fl++;
- }
- }
- if (fl==0)
- {
- break;
- }
- }
- for (j=0; j<schet1; ++j)
- {
- i=0;
- while (*(stroka[j]+i)!='\0')
- {
- putchar(*(stroka[j]+i));
- i++;
- }
- putchar('\n');
- }
- for (j=0; j<schet1; ++j)
- {
- free(stroka[j]);
- }
- free(stroka);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement