Advertisement
Guest User

Untitled

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