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