Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int apcar(char *s, int x)
- {
- int cnt = 0;
- char *p = strchr(s,x);
- while(p != NULL)
- {
- cnt ++ ;
- p = strchr(p + 1, x);
- }
- return cnt;
- }
- int main()
- {
- char s[256], *p, v[101][16];
- cin.getline(s, 256);
- int n = 0;
- p = strtok(s," ");
- while(p)
- {
- bool gasit = false;
- for(int i = 1; i <= n ; i ++)
- if(strcmp(v[i],p) == 0)
- gasit = true;
- if(!gasit)
- strcpy(v[++n], p);
- p = strtok(NULL, " ");
- }
- for(int i = 1; i< n; i ++)
- for(int j = i + 1; j <= n; j ++)
- if(strcmp(v[i],v[j]) > 0)
- {
- char t[16];
- strcpy(t,v[i]);
- strcpy(v[i], v[j]);
- strcpy(v[j], t);
- }
- for(int i =1; i <= n ; i ++)
- cout << v[i] << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement