HELP! CHEFDETECTIVE problem = ERROR IN COMPILATION

the problem in concern is Contest Page | CodeChef

My program is not compiling and I cant seem to fix it. Could anyone help me understand and correct where and what is wrong syntactically or logically? any hekp ould be appreciated

this is my code in C++
#include<stdio.h>
using namespace std

int main()
{
int a,b,i,j,str[10000],rep[10000];
cin>>a;
for(i=0;i<a;i++)
{
str[i]=i+1;
cin>>rep[i];
}
for(j=0;j<a;j++)
{
for(int k=0;k<a;k++)
{
if str[j]==rep[k]
{str[j]=-1;
 break;
 }
 }
 if str[j]!=-1;
 {cout<<str[j];}
 }
 }
 return 0;
 }

I think this for loop will give you the complilation error. why you are using “=” in cin (I’m not clear)?

for(i=0;i<a;i++) {

="" str[i]=“i+1;”
cin="">>rep[i];
}

You can check this solution. for reference.

Hope this helps!

Did you tried to run it in codechef ide and see the error?

Missing semi colon after using namespace std , no brackets for if statement, multiple errors.

your header

@srs101 The problem with your code is:

  1. Using wrong header file, use for “cin”

  2. Missing semicolon in 2nd line

  3. Bracket missing in “if” conditions

  4. Poor indentation

    #include
    #include<string.h>
    using namespace std;

    int main()
    {
    int a,b,i,j,str[10000],rep[10000];
    cin>>a;
    for(i=0;i<a;i++)
    {
    str[i]=i+1;
    cin>>rep[i];
    }
    for(j=0;j<a;j++)
    {
    for(int k=0;k<a;k++)
    {
    if (str[j]==rep[k])
    {
    str[j]=-1;
    break;
    }
    }
    if (str[j]!=-1)
    {
    cout<<str[j]<<" ";
    }
    }
    return 0;
    }

I corrected your code. Have a look and compare it with your code and use indentation in your code it will help you in finding bugs easily.