Using the example of 10, all the numbers from 1 to 10 are initially in the game. Suppose the user chooses 9; 9 is added to his score. The Tman gets 1 and 3 since these are exact divisors of 9; the Tman’s score is now 1 + 3 = 4. The numbers 1, 3 and 9 are removed from the game so the numbers remaining are 2, 4, 5, 6, 7, 8 and 10. Suppose the user chooses 6; his score is now 9 + 6 = 15. The Tman gets 2 and his score is now 4 + 2 = 6. The numbers 2 and 6 are removed from the game, leaving 4, 5, 7, 8 and 10. Note that now the user cannot choose 4, 5 or 7 since none of these has a divisor remaining in the game. Suppose he chooses 10; the Tman gets 5. The user’s score becomes 15 + 10 = 25 and the Tman’s score becomes 6 + 5 = 11. The numbers remaining are 4, 7 and 8. The user can choose only 8, making his score 33. The Tman gets 4, making his score 15. Only 7 is left in the game. Since there is nothing the user can choose, the Tman gets the remaining number(s) (7, in this example, making his score 22) and the game ends with the user being the winner.
Write a program to play the game of Tman. The first item of data requested is the upper limit (10 in the example) of the numbers in the game. Assume that the limit is less than or equal to 100. The program then repeatedly asks for the user’s choice until the game is over. For each choice entered, the program must print what the Tman gets as well as the current scores. If the user enters an invalid choice (for example, a number not in the game or a number with no divisors remaining in the game), print a message and ask for another number. At the end, print the winner.
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <conio.h>
typedef struct{
int a[11];
}number;
const int max = 11;
int main () {
number array;
int j;
int count = 0;
int y,x,z;
int sumuser;
int sumtman;
for ( j= 1; j <max; j++ ){
count = count +1 ;
array.a[j] = count;
}
do{
printf( "Enter number you want");
scanf ("%d",z);
for ( j= 1; j <max; j++ ){
if ( z == array.a[j]){
sumuser = sumuser + array.a[j];
array.a[j] = 0;
for(x = 1; x != z ; x++){
y = z%x;
if(y == 0 ){
sumtman = sumtman + x;
array.a[x] =0;
}}}}
}while(y !=0);
printf("%d\n",sumtman);
printf("%d",sumuser);
getch ();
}
i've reached this far and completely lost as to what to do again...