不用循环数组
只要一个数组 用一个while语句两个if语句就搞定。
我的代码如下 是20个学生数到3就出队列。
#include <stdio.h>
void main ()
{
int stu[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19};
int cout = 0;
int cout1 = 3;
int *p = &stu[2];
int pu;
while ( cout <= 20 )
{
if ( cout1 == 3 )
{
cout1 = 0;
pu = p-stu;
printf (" %d ", stu[pu]);
stu[pu] = -1;
}
p = &stu[( ( ( p - stu ) + 1 ) % 20 )];
if (*p != -1)
{
cout = 0;
cout1++;
}
else cout++;
}
}
************************
if (*p != -1)
{
cout = 0;
cout1++;
}
else cout++;
}
***********cout++是什么哇