Answer to Question #62972 in C for LART

Question #62972
ALGORITHM FOR NIM GAME
1
Expert's answer
2016-10-28T11:58:10-0400
#include <stdio.h>

int main() {
int n; //number of stones
scanf("%d", &n);

int i, res = 0;
for (i = 0; i < n; i++) {
int k; //numbers of stones in ith heap
scanf("%d", &k);

//finding xor-sum of sequence

res ^= k;
}

printf("%s won\n", res != 0 ? "First" : "Second");

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS