ამოხსნების სტატუსი

ამ გვერდზე თქვენ იხილავთ გაგზავნილი ამოხსნების სტატუსს.


გაგზავნის თარიღი: 24.11.2022 16:50:28

ამოცანა: გრძელი სიტყვა

მომხმარებელი: tsotniko

ვერდიქტი: ამოუხსნელი

შეფასება: 0 ქულა







#include<iostream>
using namespace std;
int i,n,k,max;
string s,s2;
main(){
    cin>>n;
    for(i=0; i<=n; i++){
        cin>>s;
        k=s.size();
        if(k>max){
            max=k;
            s2=s;
        }
        else {if (k==max && s<s2) s2=s;
    }
    cout<<s2;
}
main.cpp: In function 'int main()':
main.cpp:10:14: error: reference to 'max' is ambiguous
         if(k>max){
              ^~~
main.cpp:3:11: note: candidates are: int max
 int i,n,k,max;
           ^~~
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from main.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:265:5: note:                 template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:219:5: note:                 template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
main.cpp:11:13: error: reference to 'max' is ambiguous
             max=k;
             ^~~
main.cpp:3:11: note: candidates are: int max
 int i,n,k,max;
           ^~~
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from main.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:265:5: note:                 template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:219:5: note:                 template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
main.cpp:14:22: error: reference to 'max' is ambiguous
         else {if (k==max && s<s2) s2=s;
                      ^~~
main.cpp:3:11: note: candidates are: int max
 int i,n,k,max;
           ^~~
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from main.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:265:5: note:                 template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:219:5: note:                 template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
main.cpp:17:1: error: expected '}' at end of input
 }
 ^