Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 3
- #include <iostream.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
- #define DELIMITERS " .,:;\n\t"
- void function2(char *a)
- {
- char max[20]; int i=0,j=0;
- while(a[i]!='\0')
- {
- if (strlen(a)>j)
- j=strlen(a);
- max[i]=a[i];
- i++;
- }
- printf("max length\n");
- puts(max);
- }
- void Sort(char *a[], int n)
- {
- int i, j, k;
- char min, *buf;
- for(i = 0; i < n-1; i++)
- {
- min = a[i][0];
- k = i;
- for(j = i + 1; j < n; j++)
- if (a[j][0] < min)
- {
- k = j;
- min = a[j][0];
- }
- buf = a[i]; a[i] = a[k]; a[k] = buf;
- }
- }
- int main()
- {
- char s[500];
- char *a[100];
- char *word;
- int i, n = 0;
- printf("Str= ");
- fgets(s,500,stdin);
- word=strtok(s,DELIMITERS);
- while(word!=NULL)
- {
- a[n++] = word;
- word=strtok(NULL,DELIMITERS);
- }
- for(i = 0; i < n; i++)
- puts(a[i]);
- Sort(a, n);
- puts("\n");
- for(i = 0; i < n; i++)
- puts(a[i]);
- puts("\n");
- function2(word);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement