take two stones problem unwanted 0 in print

Hello again, I'm working on the kattis twostones problem for the cs1 class I started recently. It runs correctly and solves the problem, but when it prints it says 0Bob Wins! instead of just Bob Wins. any ideas as to why? thanks in advance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Take Two Stones
Kattis Practice
By: Andrew Libberton
9/7/2018

This program is designed to determine who would win in a game of stones where Alice and Bob choose a 2 consecutive stones two at a time 
taking turns until there are no consecutive stones left.  Both players play optimally. If there are an odd number of stones Alice wins
even number of stones Bob wins.  Alice goes first and there are 1000000

1. Create integer representing the number of possible stones 1000000 : N
2. input the value the of N, (1 <= N <= 1000000)
3. Create if else statement to determine winner
4. Create an output to tell who wins
*/

#include <iostream>
#include <cmath>
#include <string>
#include <stdbool.h>


using namespace std;

int main() { 
	int N;

	N = 0;
	
	N = (1 <= N && N <= 10000000); //FIXME'<='; unsafe use of bool //fixed &&
	
	if (N % 2 == 0) //fixed removed ;

		cout << N << "Bob Wins!" << endl;
	
	else //(N % 2 == 1); didn't fix // illegal else without matching if c2181 //fixed if
	
		cout << N << "Alice Wins!" << endl;
	


		

	cin.get(); //Fixed added ()
	return 0;
}
Last edited on
 
cout << N << "Bob Wins!" << endl;
Last edited on
totally makes sense! I added it when i was trying to fix a illegal if else error forgot to remove it. much appreciated peter
Topic archived. No new replies allowed.