Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //
- //
- #include<stdio.h>
- #include<math.h>
- int main(void)
- {
- int t, s, doors[100], dr_num, open, total=0;
- for(t = 0; t < 100; t++) //setting array initial values to 0
- {
- doors[t] = 0;
- }
- for(s = 0; s < 100; s++) //for loop to jump through all 100 students
- {
- for(t = 0; t < 100; t++) //for loop that steps through all 100 time steps
- {
- dr_num = (t * s) - 1;
- if(dr_num >= 100)
- {
- break;
- }
- else if(doors[dr_num] == 0)
- {
- doors[dr_num] = 1;
- }
- else
- {
- doors[dr_num] = 0;
- }
- }
- }
- printf("This is the status of the doors:\n");
- for(t = 0; t < 100; t++)
- {
- open = t+1;
- printf("Door:%d : %d \n",open, doors[t]);
- total = total + doors[t];
- }
- printf("\nThe total amount of doors open is: %d\n", total);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement