Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. using namespace std;
  5. ifstream in("sortcuv.in");
  6. ofstream out("sortcuv.out");
  7. int main()
  8. {
  9. char s[251],*p,v[200][21],aux[21];
  10. int i,j,n=0;
  11. in.getline(s,251);
  12.  
  13. p=strtok(s," ");
  14. while(p!=NULL)
  15. {
  16. n++;
  17. strcpy(v[n],p);
  18. p=strtok(NULL," ");
  19. }
  20.  
  21.  
  22. for(i=1;i<n;i++)
  23. for(j=i+1;j<=n;j++)
  24. if(strcmp(v[i],v[j])==1)
  25. {
  26. strcpy(aux,v[i]);
  27. strcpy(v[i],v[j]);
  28. strcpy(v[j],aux);
  29. }
  30. for(i=1;i<=n;i++)
  31. out<<v[i]<<endl;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement