Advertisement
SelinD

71

Jun 28th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. #include<fstream>
  4. using namespace std;
  5. ifstream fin("cuvinte.in.cpp");
  6. char c[1001][21],aux[21];
  7. int main()
  8. {
  9. int i,j,n;
  10. fin>>n;
  11. for(i=1;i<=n;i++) fin>>c[i];
  12.  
  13. for(i=1;i<=n;i++)
  14. {
  15. for(j=i+1;j<=n;j++)
  16. {
  17. if(strlen(c[i])>strlen(c[i+1]))
  18. {
  19. strcpy(aux,c[i]);
  20. strcpy(c[i],c[i+1]);
  21. strcpy(c[i+1],aux);
  22. }
  23. }
  24. }
  25. for(i=1;i<=n;i++)
  26. {
  27. cout<<c;
  28. cout<<endl;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement