Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include<stdio.h>
  2. int checkallout(char *people);
  3. int main()
  4. {
  5. int i,j;
  6. char people[101];
  7. for(i=1;i<=100;i++)
  8. {
  9. people[i]='y';//setting all people with badges everyone is in now
  10. }
  11. i=1;
  12. j=1;
  13. while(checkallout(people)>1)
  14. {
  15. if(j==10)
  16. {
  17. if(people[i]=='y')
  18. {
  19. people[i]='x';
  20. printf("\n%d is out ",i);
  21. j=1;
  22. }
  23. }
  24. else
  25. {
  26. //printf("\n%d not out yet",i);
  27. j++;
  28. }
  29. i++;
  30. if(i>100)
  31. i=1;
  32.  
  33. }
  34. for(i=1;i<=100;i++)
  35. {
  36. if(people[i]=='y')
  37. {
  38. printf("\n %d is last number remaining",i);
  39. break;
  40. }
  41. }
  42. /* to see how many people are out and who is in visually
  43. for(i=1;i<=100;i++)
  44. printf("\n people[%d]=%c",i,people[i]);
  45.  
  46. */
  47. return 0;
  48. }
  49. int checkallout(char *people)
  50. {
  51. int i,j;
  52. j=0;
  53. for(i=1;i<=100;i++)
  54. if(people[i]=='y')
  55. j++;
  56. return j;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement