TopCoder Coding Environment Linker Error

I am trying to present a solution to a problem in TopCoder, which requires a presentation to execute its predefined classes and methods . Since I'm new to TopCoder, I'm basically trying to customize the encoding interface. This code compiles fine on my computer. Unfortunately, on TopCoder I get errors:

Your code did not compile:

error binding:

AdditionGame-stub.o: In main': AdditionGame-stub.cc:(.text.startup+0x0): multiple definition of main' AdditionGame.o: AdditionGame-stub.cc :(. Text.startup + 0x0): first defined here collect2: error: ld returned 1 exit status

Help me please. Here is my code:

  class AdditionGame { public: int getMaximumPoints(int a, int b, int c, int n){ int temp; if(a<b){temp=a; a=b; b=temp;} if(b<c){temp=b; b=c; c=temp;} int sum=0; for(int i=0; i<n; i++){ if(a>0){sum=sum+a;} if(a>0){a=a-1;} if(a<b){temp=a; a=b; b=temp;} if(b<c){temp=b; b=c; c=temp;} } return sum; } }; #include <iostream> #include <algorithm> using namespace std; int main(){ AdditionGame add; int A,B,C,N; cin>>A>>B>>C>>N; int p = add.getMaximumPoints(A, B, C, N); cout<<p; return 0; }` 
+6
source share
1 answer

It seems that TopCoder defines the main () function for you based on your error message.

+4
source

All Articles