I was doing the PlusMinus question of hackerrank so it was coming out wrong. To check for the mistake I ran it in Clion but the error showed up. Can someone please tell me why this happened and what should I do so that this error does not show up again ?
Error
duplicate symbol '_main' in:
CMakeFiles/Clion.dir/main.cpp.o
CMakeFiles/Clion.dir/plus_minus.cpp.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Code
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
void plusMinus(vector<int> arr) {
float i,pos,neg,zero;
//n=arr.size();
for(i=0;i<arr.size();i++)
{
if(arr.at(i)<0)
neg++;
else if(arr.at(i)>0)
pos++;
else if(arr.at(i)==0)
zero++;
}
pos=pos/arr.size();
neg=neg/arr.size();
zero=zero/arr.size();
cout<<fixed<<setprecision(6)<<pos<<"\n"<<neg<<"\n"<<zero;
return ;
}
int main()
{
int n,temp;
cin>>n;
vector<int> arr;
for(int i=0;i<n;i++)
{
cin>>temp;
arr.push_back(temp);
}
plusMinus(arr);
}
Aucun commentaire:
Enregistrer un commentaire