Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int checkallout(char *people);
- int main()
- {
- int i,j;
- char people[101];
- for(i=1;i<=100;i++)
- {
- people[i]='y';//setting all people with badges everyone is in now
- }
- i=1;
- j=1;
- while(checkallout(people)>1)
- {
- if(j==10)
- {
- if(people[i]=='y')
- {
- people[i]='x';
- printf("\n%d is out ",i);
- j=1;
- }
- }
- else
- {
- //printf("\n%d not out yet",i);
- j++;
- }
- i++;
- if(i>100)
- i=1;
- }
- for(i=1;i<=100;i++)
- {
- if(people[i]=='y')
- {
- printf("\n %d is last number remaining",i);
- break;
- }
- }
- /* to see how many people are out and who is in visually
- for(i=1;i<=100;i++)
- printf("\n people[%d]=%c",i,people[i]);
- */
- return 0;
- }
- int checkallout(char *people)
- {
- int i,j;
- j=0;
- for(i=1;i<=100;i++)
- if(people[i]=='y')
- j++;
- return j;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement