Advertisement
Guest User

es3

a guest
Mar 30th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. void Concatena(char[][80], int);
  5. int main()
  6. {
  7. char S[80];
  8. cin.getline(S,80);
  9. int N;
  10. cin>>N;
  11. char A[N][80];
  12. int cont=0;
  13. bool vera=false;
  14. while(cont<=N)
  15. {
  16. cin.getline(A[cont],80);
  17. cont++;
  18. }
  19. char Temp1[80];
  20. char Temp2[80];
  21. for(int i=0;i<=N;i++)
  22. for(int k=1;k<=N;k++)
  23. {
  24. strcpy(Temp1,A[i]);
  25. strcpy(Temp2,A[k]);
  26. strcat(Temp2,A[i]);
  27. strcat(Temp1,A[k]);
  28. if((strcmp(Temp1,S)==0) || (strcmp(Temp2,S)==0))
  29. vera=true;
  30. }
  31. if(vera)
  32. cout<<"OK";
  33. else
  34. Concatena(A,N);
  35. return 0;
  36.  
  37. }
  38. void Concatena(char A[][80], int N)
  39. {
  40. char stringaMinore[80];
  41. char stringaMaggiore[80];
  42. strcpy(stringaMinore,A[0]);
  43. strcpy(stringaMaggiore,A[0]);
  44. for(int i = 0; i < N; i++)
  45. {
  46. if((strcmp(stringaMaggiore, A[i])) < 0)
  47. strcpy(stringaMaggiore, A[i]);
  48. if((strcmp(stringaMinore, A[i])) > 0)
  49. strcpy(stringaMinore, A[i]);
  50. }
  51. cout<<stringaMaggiore<<stringaMinore;
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement