64 570
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #62972 in C for LART

Question #62972
ALGORITHM FOR NIM GAME
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions