帮我看看哪里有问题啊 约瑟夫问题 为什么输出结果的时候总是会显示一个指令错误
#include <stdio.h>#include<stdlib.h>
#include<string.h>
#define N 2
#define len_name 15
void yuesefu(struct data stu[],int m);
struct data
{
char name[len_name];
char gender[2];
int age;
char num[len_name];
int password;
}stu[N],out[N];
int main()
{
int i,m;
for (i = 0; i < N; i++)
{
printf(" please input %d/%d personal information:\n", i + 1,N);
printf("please input the name:");
scanf("%s", stu[i].name);
printf("input the gender:(F or M)");
scanf("%s", stu[i].gender);
printf("input the age:");
scanf("%d", &stu[i].age);
printf("Enrter the number:");
scanf("%s", stu[i].num);
printf("input the password:");
scanf("%d", &stu[i].password);
printf("\n");
}
printf("Please enter the number to start out");
scanf("%d", &m);
yuesefu(stu,m);
return 0;
}
void yuesefu(struct data stu[], int m)
{
int i, mark = 0, count = 0;
int r[N];
for (i = 0; i < N; i++)
r[i] = stu[i].password;
while (1)
{
for (i = 0; i < N; i++)
{
if (r[i]>0)
{
mark++;
if (mark == m)
{
strcpy(out[count].name,stu[i].name);
strcpy(out[count].gender,stu[i].gender);
out[count].age=stu[i].age;
strcpy(out[count].num,stu[i].num);
out[count].password=stu[i].password;
m = r[i];
r[i] = 0;
mark = 0;
count++;
}
}
}
if (count == N)
break;
}
printf("Out of the people:\n");
for (i = 0; i < N; i++)
printf("Name :%s\ngender:%s\nage:%d\nnum%s\npassword :%s\n", out[i].name, out[i].gender, out[i].age, out[i].num, out[i].password);
}