Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- void Concatena(char[][80], int);
- int main()
- {
- char S[80];
- cin.getline(S,80);
- int N;
- cin>>N;
- char A[N][80];
- int cont=0;
- bool vera=false;
- while(cont<=N)
- {
- cin.getline(A[cont],80);
- cont++;
- }
- char Temp1[80];
- char Temp2[80];
- for(int i=0;i<=N;i++)
- for(int k=1;k<=N;k++)
- {
- strcpy(Temp1,A[i]);
- strcpy(Temp2,A[k]);
- strcat(Temp2,A[i]);
- strcat(Temp1,A[k]);
- if((strcmp(Temp1,S)==0) || (strcmp(Temp2,S)==0))
- vera=true;
- }
- if(vera)
- cout<<"OK";
- else
- Concatena(A,N);
- return 0;
- }
- void Concatena(char A[][80], int N)
- {
- char stringaMinore[80];
- char stringaMaggiore[80];
- strcpy(stringaMinore,A[0]);
- strcpy(stringaMaggiore,A[0]);
- for(int i = 0; i < N; i++)
- {
- if((strcmp(stringaMaggiore, A[i])) < 0)
- strcpy(stringaMaggiore, A[i]);
- if((strcmp(stringaMinore, A[i])) > 0)
- strcpy(stringaMinore, A[i]);
- }
- cout<<stringaMaggiore<<stringaMinore;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement