Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- char s[10001],sep[]=" .,";
- char cuv[101][101],*p,aux[101];
- int n;
- void Citire()
- {
- cin.getline(s, 10000);
- p=strtok(s,sep);
- while(p)
- {
- strcpy(cuv[++n],p);
- p=strtok(0,sep);
- }
- }
- void Sortare()
- {
- bool ter=0;
- while(!ter)
- {
- ter=1;
- for(int i=1; i<n; i++)
- if(strcmp(cuv[i],cuv[i+1])>0)
- {
- strcpy(aux,cuv[i]);
- strcpy(cuv[i],cuv[i+1] );
- strcpy(cuv[i+1],aux);
- ter=0;
- }
- }
- }
- void Afisare()
- {
- for(int i=1; i<=n; i++)
- cout<<cuv[i]<<' ';
- }
- int main()
- {
- Citire();
- Sortare();
- Afisare();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment