Originally Posted by
Salem
Perhaps start with
Code:
int picked[5] = { 0 };
When the user chooses a number 'num', you do
picked[num] = 1;
When it comes to displaying numbers to choose, you do
if ( picked[n] != 1 ) print n
Thanks for this. Though I'm here to learn, with the limited knowledge that I have, still can't implement your suggestion.
So far, I was able to accomplish only this chunk of code:
Code:
int len,choice,i,j;
int nums[5] = {1,2,3,4,5};
printf("Available numbers:\n");
for(i=0; i<5; i++)
printf("Numbers: %d\n", nums[i]);
len = 5;
do
{
printf("\nChoose a number: or press '6' to exit)\n");
scanf("%d",&choice);
for(i=0;i<len;i++)
{
if(nums[i]==choice)
{
for(j=i;j<len;j++)
nums[j]=nums[j+1];
len--;
}
}
printf("\nNumbers left:\n");
for(i=0;i<len;i++)
{
printf("Numbers: %d \n",nums[i]);
if(nums[i]== '\0') // want to check if the array is empty to display the message below
printf("none left\n");
}
}
while(choice<6);
I understand that the exit condition isn't the best one, could you suggest anything?