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