SRM 컴파일 질문입니다.ㅋ

  • @,.@
    @,.@

    이번에 처음으로 탑코더를 해봤는데요. 컴파일이 안되네요.
    C++로
    int main()
    {
    return 0;
    }
    이렇게 해서 컴파일 해보니..
    Your code did not compile:
    errors compiling:
    Your class or method was improperly declared: In function ‘int _wrapper::thunk(std::vector >)’:
    Your class or method was improperly declared:20003: error: invalid use of undefined type ‘struct TrueStatements’
    end of your submission:10030: error: forward declaration of ‘struct TrueStatements’
    이런 메세지가 뜨네요.ㅋ
    왜그런가요??ㅋ
    쩝... 문제만 읽고 갑니다.ㅋㅋ

    [이 글은 과거 홈페이지에서 이전된 글입니다. 원문보기]

    16년 전
2개의 댓글이 있습니다.
  • hyunhwan
    hyunhwan

    c++ 코딩시 int main() 함수가 들어가선 안됩니다. 그럴경우 생기는 에러인걸로 생각되는데요,
    탑코더의 경우엔 문제에 명시된 class를 작성한다고 보시면 됩니다.
    다음은 이번 SRM div1 250 코드입니다. 연습방에 들어가신 다음에 코드를 그대로 집어넣고 submit 해보시면 가동이 될겁니다. 아래에도 마찬가지로 int main() 은 빠져 있습니다.

    #include <cctype>
    #include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include <sstream>
    #include <utility>
    using namespace std;
    typedef long long ll;
    #define clr(x,v) memset(x,(v),sizeof(x))
    #define all(x) (x).begin(),(x).end()
    #define pb(x) push_back(x)
    #define sz(x) (int)(x).size()
    template<typename T> string tostr(T x) { ostringstream ret; ret << x; return ret.str(); }
    struct TrueStatements {
      int numberTrue(vector <int> vs) {
        int f[51]={0};
        for(int i=0;i<sz(vs);++i) f[vs[i]]++;
        for(int i=50;i>=1;--i) {
          if(f[i]==i) return i;  
        }
        if(f[0]==0) return 0;
        else return -1;
      }
    };
    

    16년 전 link
  • @,.@
    @,.@

    답변 감사합니다..^^;;


    16년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.