Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream f("interesant.in");
- ofstream g("interesant.out");
- int main()
- {
- int p, n; f >> p >> n;
- char mat[n][5001];
- for(int i = 0; i<n; ++i){
- f >> mat[i];
- }
- if(p==1)
- {
- bool sortat = false;
- while(!sortat)
- {
- sortat = true;
- for(int i = 0; i<n-1; ++i)
- {
- if(strlen(mat[i]) > strlen(mat[i+1])){
- char temp[5001];
- strcpy(temp, mat[i]);
- strcpy(mat[i], mat[i+1]);
- strcpy(mat[i+1], temp);
- sortat = false;
- }
- if(strlen(mat[i]) == strlen(mat[i+1]))
- {
- if(strcmp(mat[i], mat[i+1]) < 0)
- {
- char temp[5001];
- strcpy(temp, mat[i]);
- strcpy(mat[i], mat[i+1]);
- strcpy(mat[i+1], temp);
- sortat = false;
- }
- }
- }
- }
- g << mat[n-1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement