修改文件结构。
This commit is contained in:
32
POP/11/Exercise2.c
Normal file
32
POP/11/Exercise2.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#define INCIRCLE false
|
||||
#define OUTCIRCLE true
|
||||
|
||||
void del(int *p, int m) {
|
||||
int nowPos = 0, count = 0, outCount = 0;
|
||||
for (outCount = 0; outCount < m - 1; outCount++) {
|
||||
count = 0;
|
||||
while (count < 3) {
|
||||
if ( *(p + nowPos) == INCIRCLE) {
|
||||
count++;
|
||||
}
|
||||
nowPos = (nowPos + 1) % m;
|
||||
}
|
||||
*(p + ((nowPos + m - 1) % m)) = OUTCIRCLE;
|
||||
}
|
||||
for (;;nowPos = (nowPos + 1) % m) {
|
||||
if (*(p+nowPos) == INCIRCLE) {
|
||||
printf("%d\n", nowPos + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int num[50] = {0};
|
||||
int n = 0;
|
||||
scanf("%d", &n);
|
||||
del(num, n);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user