Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- char text[256], s[256][256];
- gets(text);
- char sep[] = " .,";
- char *p = strtok(text, sep);
- int k = 0;
- while (p)
- {
- strcpy(s[k], p);
- k++;
- p = strtok(NULL, sep);
- }
- for (int i = 0; i < k - 1; i++)
- for (int j = i + 1; j < k; j++)
- if (strcmp(s[i], s[j]) > 0)
- {
- char aux[256];
- strcpy(aux, s[i]);
- strcpy(s[i], s[j]);
- strcpy(s[j], aux);
- }
- for (int i = 0; i < k; i++)
- cout << s[i] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement