#include<stdio.h>
#include<
string.h>
#define MAX 1000+10
int _light[MAX];
int main()
{
int light =
0,_allLight =
0, i =
0, j =
0, _preson =
0, firstPreson =
1;
memset(_light,0,
sizeof(_light));
printf("please enter the all light and preson: ");
scanf("%d %d", &_allLight, &
_preson);
for(i =
1; i <= _preson; i++
)
for(j =
1; j <= _allLight; j++
)
if(j%i ==
0) _light[j] = !_light[j];
//利用开关灯就是0和1的特性 还有数组下标就是灯的位置
for(i =
0; i <= _allLight; i++
)
{
if(_light[i])
{
if(firstPreson)
firstPreson =
0;
else
printf(" ");
printf("%d",i);
}
}
printf("\n");
return 0;
}
转载于:https://www.cnblogs.com/-monster/p/4780996.html
相关资源:各显卡算力对照表!