I have framed an error into a question.
I keep getting 2 output results alternating randomly(sometimes its '1' and sometimes its '0',even though the input is same .
can someone explain me why is this happening? compiler issue?
i am pretty sure a set of commands with same input cant change it's output every time you run it.
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int N ,M;
cin>>M>>N;
int arr[N];
int turn=-1;
char win='D';
for(int i=0;i<N;i++)
{
if(M>0)
{
if(turn==-1)
{
M=M-arr[i];
win='D';
}
else if(turn==1)
{
M=M-arr[i];
win='K';
}
}
else
break;
turn=turn*-1;
}
if(win=='K')
{
cout<<"Kate"<<endl;
}
else if(win=='D')
{
cout<<"Little Deepu"<<endl;
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire